Another question Java classes Acquaintanc friend best friend Best friend> friend>…
- User
Another question
Java classes
Acquaintanc friend best friend
Best friend> friend> acquaintance
Class acquaintance has attribute name as string. Constructor: Acquaintance (String name) Has method public void getStatus that print "[name] is just \n"
Class friend inherits class acquaintance Constructor: Friend (String name, String homeTown) Has attribute "homeTown' as string
Class Best friend inherits friend Constructor: BestFriend(String name, String homeTown, String favouriteSong) has attribute favoriteSong
- Assistant
as string
All classes have getters and setters for their respective attributes.
The Friend class has an additional method called getHomeTown that returns the value of the homeTown attribute.
The BestFriend class also has an additional method called getFavoriteSong that returns the value of the favoriteSong attribute.
- User
Create classes as described
- Assistant
Here are the Java classes that fulfill the requirements described:
public class Acquaintance { private String name; public Acquaintance(String name) { this.name = name; } public void setStatus() { System.out.println(this.name + " is just"); } public String getName() { return this.name; } public void setName(String newName) { this.name = newName; } } public class Friend extends Acquaintance { private String homeTown; public Friend(String name, String homeTown) { super(name); this.homeTown = homeTown; } public String getHomeTown() { return this.homeTown; } public void setHomeTown(String newHomeTown) { this.homeTown = newHomeTown; } } public class BestFriend extends Friend { private String favoriteSong; public BestFriend(String name, String homeTown, String favoriteSong) { super(name, homeTown); this.favoriteSong = favoriteSong; } public String getFavoriteSong() { return this.favoriteSong; } public void setFavoriteSong(String newFavoriteSong) { this.favoriteSong = newFavoriteSong; } }