Menu

[Solved]Given Following Person Object Class Answer Questions Follow Public Class Person Protected Q37042770

Given the following Person object class, answer the questionsthat follow.

public class Person {

protected String name;

protected int age;

public Person() {

} public Person(String name, int age)

{

this.name = name;

this.age = age; }

public void play() {

System.out.println(“Out having fun…”);

}

ublic void talk() {

System.out.println(“Hi!”);

}

public void setName(String name) {

this.name = name;

}

public String getName() {

return name;

}

public void setAge(int age) {

this.age = age;

}

public int getAge() {

return age;

}

public String toString() {

StringBuffer buffer = new StringBuffer();

buffer.append(“nname: ” + name);

buffer.append(“nage: ” + age);

return buffer.toString();

}

}

Write a Java class Pilot that that extends the Person object.Add the member variables grade as a string (i.e. Recreational,Private, Commercial, and ATP), isCurrent as a boolean, and numHoursas an integer. Override the play() method to output “I cannot play!I am boarding the plane…”, and override the talk() method tooutput “Redstone Traffic, Cessana Niner Seven Niner One Foxtrottaxiing to runway 35!”. Add the method takeoff() which outputs thestring “Redstone Traffic, Cessana Niner Seven Niner One Foxtrotdeparting 35”. Add another method landing() which outputs thestring “Redstone Traffic, Cessana Niner Seven Niner One Foxtrotfinal runway 17 full stop”. The Pilot object class should overridethe toString() method and display all variables (including theinherited ones).

Expert Answer


Answer to Given the following Person object class, answer the questions that follow. public class Person { protected String name; … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *