Skip to content

Instantly share code, notes, and snippets.

@Villach927
Last active July 6, 2017 01:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Villach927/7d0d807a1c911a47832afc1bf3d51ccb to your computer and use it in GitHub Desktop.
Save Villach927/7d0d807a1c911a47832afc1bf3d51ccb to your computer and use it in GitHub Desktop.
オブジェクト指向講座_サンプル1
import java.util.*;
class Main{
public static void main(String[] args){
Dog dogA = new Dog();
dogA.bark();
dogA.paw();
Bird birdA = new Bird();
birdA.age = 5;
System.out.println(birdA.age);
}
}
class Animal{
public int age;
public void bark(){
System.out.println("鳴く");
}
}
class Dog extends Animal{
public int hairColor;
public void paw(){
System.out.println("お手をする");
}
}
class Bird extends Animal{
public int beakColor;
public void peck(){
System.out.println("ついばむ");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment