0

Airplane Java

Can someone help me complete this java code? Implement the following reviews: • Aircraft: maxSpeed ​​must never be less than 200 • Aircraft: The description property in the pilot's skill must match the designation of the aircraft Implement the following methods: • Aircraft: toString () method should output [Type] with [maxSpeed] top speed Examples: o Glider with 200 maximum speed o Motor airplane with 500 top speed The type you get when you click the object variable (here x) following method execute: x.getClass (). getName () Code: https://code.sololearn.com/cWNXV6G3o210/#java

13th Nov 2019, 7:26 PM
Micelito
Micelito - avatar
5 odpowiedzi
+ 1
It is seems like assignment. So you should do it by yourself. I can only give some idea. Define aircraft class with type, topspeed, designation propertys with setters and getters. Or constructor which sets all property's.. getName=> should return type's value. A description function which prints details. toString() => return x.getName().getName(); define pilot class with name, topskill, with setter ,getters, or with a construtor Create objects in main class, set properties, method as with different type setting, print object as your requirement... ex: aircraft a=new aircraft(glider,200,designation1); pilot p=new pilot(sam,200,skill1); if(designation==pilotskill) System.out.println(a); hoping it gives you some idea....
13th Nov 2019, 8:28 PM
Jayakrishna 🇮🇳
+ 1
public class Main() { ... main(...) { Motorflugzeug flugzeugM = new Motorflugzeug(); Skill skillM = new Skill("Motorflugzeug"); Pilot pilotM = new Pilot(skillM); boolean pilotIsOK = flugzeugM.setPilot(pilotM); // +check skill of pilot System.out.println("Check pilot of Motor airplane: "+pilotIsOK); System.out.println(flugzeugM); } } public abstract class Flugzeug { // private String bezeichnug; - // typo bezeichnu(n)g private String bezeichnung = this.getClass().getName(); //airplane type by class name ... public boolean setPilot(Pilot pilot) { // check skill of pilot here ... this.pilot = pilot; return ... } // @Override - top level class, here is nothing to override public String toString() { // return this.pilot; return bezeichnung; //incomplete } } // public class Motorflugzeug { public class Motorflugzeug extends Flugzeug { ... @Override public String toString() { //not necessary but I respect your Class diagram // return this.anzahlMotoren; return super.toString(); } } // public class Segelflugzeug { public class Segelflugzeug extends Flugzeug { @Override public String toString() { return super.toString(); } } public class Pilot { ... // public Pilot(String name) { public Pilot (Skill skill) { this.skill = skill; } ... } public class Skill { ... Skill(String beschreibung) {this.beschreibung = beschreibung;} ... } public class Fluggesellschaft { ... public Flugzeug getFlugzeug(int index) { // this.flugzeuge.get(index); return this.flugzeuge.get(index); } }
15th Nov 2019, 8:43 PM
zemiak
0
I start with this changes: //public abstract class Flugzeug { ... //public boolean setPilot(Pilot pilot) { public void setPilot(Pilot pilot) { this.pilot = pilot; } public String getBezeichnug() { return bezeichnug; } public void setBezeichnug(String bezeichnug) { this.bezeichnug = bezeichnug; } ... @Override public String toString() { return bezeichnug+" "+pilot+" "+maxSpeed; } } class Pilot { String name; Pilot( String name) {this.name=name;} public String toString() { return name; } } class Flugzeug_Test { public static void main(String[] args) { Flugzeug fl = new Flugzeug(); fl.setBezeichnug("type"); fl.setMaxSpeed(300); fl.setPilot( new Pilot("name") ); System.out.println(fl); } }
14th Nov 2019, 12:04 AM
zemiak
0
Jaya krishna, zemiak thank you. Here is my code in the IntelliJ Project - https://1drv.ms/u/s!AiKut9QDdMBEiQyCZdC9IQAK7a99?e=qnN1k0 Please, can someone check it out? THX
14th Nov 2019, 12:08 PM
Micelito
Micelito - avatar
0
thank you
15th Nov 2019, 11:10 PM
Micelito
Micelito - avatar