Java classes and Interfaces practice--coursera Java Course Jobs
1, note that the code should use the grammatical elements required in the topic;
2, pay attention to good code style;
3, attention to submit the entire project, upload compressed attachments, mutual evaluation can be successfully executed;
4, pay attention to write a brief code description (please explain the use of the IDE, etc.);
Write a small program that defines interfaces, classes, abstract classes, define their members (fields and methods), and requires the use of Setter/getter, static, final, abstract, @Override, and other grammatical elements, and write a main function to use them. These classes, interfaces can be around one of the following topics
The topic is: Flying the world: to a flight relay (that is, a number of objects can be flown in turn call);
1 /********************************** Development Tools eclipse***********2 ********************************* title: Flying Relay *************3 */4 PackageWeek4_1;5 6 Interfaceflyable{7 voidfly ();8 }9 Abstract classAnmialImplementsflyable{Ten Public voidFly () { OneSystem.out.println ("Start flying"); ASystem.out.println ("End of Flight"); -}//@Override - } the classFlyerextendsanmial{ - PrivateString anmial; - protected Static Final intdistance=100; - Public voidSetter (String anmial) { + This. anmial=anmial; - } + PublicString getter (String anmial) { A returnanmial; at } - Public voidfiying () { -System.out.println ("Start" +distance+ "M in Flight"); -System.out.println ( This. anmial+ "End of Flight"); - } - Public voidFly () { inSystem.out.println ( This. anmial+ "Start flying"); -}//@Override to + - Public classFlyjieliextendsflyer{ the * } $ Public Static voidMain (string[] args) {Panax NotoginsengSYSTEM.OUT.PRINTLN ("The Flight relay competition officially begins!") "); - //TODO Auto-generated method stubs theString anmial1= "Brid1"; +String anmial2= "Brid2"; AString anmial3= "BRID3"; theString anmial4= "Brid4"; +String anmial5= "BRID5"; -Flyer brid1=NewFlyer (); $ Brid1.setter (ANMIAL1); $ brid1. Fly (); - brid1.fiying (); -Flyer brid2=NewFlyer (); the Brid2.setter (anmial2); - Brid2. Fly ();Wuyi brid2.fiying (); theFlyer brid3=NewFlyer (); - Brid3.setter (ANMIAL3); Wu brid3. Fly (); - brid3.fiying (); AboutFlyer brid4=NewFlyer (); $ Brid4.setter (ANMIAL4); - Brid4. Fly (); - brid4.fiying (); -Flyer brid5=NewFlyer (); A Brid5.setter (ANMIAL5); + brid5. Fly (); the brid5.fiying (); -SYSTEM.OUT.PRINTLN ("The flight relay race is over!" "); $ the } the the}
2015-05-15 20:29:15
Java class and interface exercises