Commit f7ceacff authored by Egita Udodova's avatar Egita Udodova
Browse files

Upload New File

parent 935020db
public class main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Dog shepherd = new Dog("Reksis", "Brown", 30);
Dolphin atlantic = new Dolphin("Andris", "Blue", 200);
Kangaroo roo = new Kangaroo("Roo", "White", 100);
//iekapsulēšanas piemērs
System.out.println(shepherd.getName());
shepherd.setName("Rufus");
System.out.println(shepherd.getName());
//polimorfisma paraugi
Animal animals [] = {shepherd, atlantic, roo};
for(Animal animal: animals) {
System.out.println(animal.display());
animal.move();
animal.speak();
}
Animal rex = new Dog("Pifs", "black", 15);
Animal boo = new Kangaroo();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment