Last active
July 6, 2017 01:28
-
-
Save Villach927/7d0d807a1c911a47832afc1bf3d51ccb to your computer and use it in GitHub Desktop.
オブジェクト指向講座_サンプル1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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