Question: I need the answer in java please. Thank you. Implement the class Country only. The code of the classes Road, Street and Freeway is provided

I need the answer in java please. Thank you.
I need the answer in java please. Thank you. Implement the class
Country only. The code of the classes Road, Street and Freeway is

Implement the class Country only. The code of the classes Road, Street and Freeway is provided below. Country - name: String Road - roads: ArrayList - speed Limit: int + Country[name: String) - length: int + getName(): String - carpool: boolean + getRoads(): ArrayList + Road ---All Parameters----> + addRoad(r: Road): void + setters/getters + countStreets(): int +toString(): String + searchForStreetf(streetName: String): Street + toString(): String Street name: String + Street ----All Parameters----) + setter/getter + toString(): String Freeway - code: int + Freeway ----All Parameters----) + setter/getter + toString(): String A. Implement the class country. Write the following methods: a) A constructor to initialize the name and create the arrayList roads. b) The methods getName() and getRoads(). c) The cout Streets method that returns the number of streets in the array list. d) The searchForStreetmethod that takes as parameter the name of a street and returns the street object if found or null if not found e) A toString method to return information about all data fields. B. The Road class is characterized by an int speedLimit, a int length, and a boolean carpool. The code is below: public class Road private int speedlimit, length private boolean carpool; public Road (int speedlimit, int length, boolean carpool) this.speed limit = speed Limit: this.length - length: this.carpool - carpool; //Setters and getters are skipped here. Assume they exist if you need any of them. public String toString() return "Road length + length +", speed limit is" speedlimit " and carpool lane is " + (carpool ? "available." : "not available."); C. The Street class inherits from the class Road. The code is below: public class street extends Road private String name; public Street (String name, int speedlinit, int length, boolean carpool) super (speedlimit, length, carpool); this.name name, public String getName() 1 public void setName (String name) this.name = name; 1 @Override public String tostring) return "This is " + name." st. + super.toString(): return name D. The Freeway class inherits from the class Road. The code is below: public class Freeway extends Road private int code: public Freeway (int code, int speedlinit, int length, boolean carpool) super (speedlimit, length, carpool): this.code - code: public int getCode() return code; 1 public void setCode (int code) this.codecode: 1 @Override public String toString() return "This is freeway" code + super.toString(); Question 2 [20 points) Write a client class (application in which you: a) Create a country object with name read from the user, and add to the country object some freeways and streets as many as the user wants. b) Write code to display the number of streets in the country object c) Write code display the information the country object. d) Test the searchForStreet method by reading a street name from the user and displaying its description if it is available

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!