Question: java: asap pls Part II: ArrayList and Inheritance [40 points) Question 1 [20 points) Implement the class Country only. The code of the classes Road,

Part II: ArrayList and Inheritance [40 points) Question 1 [20 points) 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... + addRoadr: Road): void + countStreets(): Int + setters/getters + searchForStreetf(streetName: String): toString(): String Street + toString(): String Street Freeway - name: String - code: Int A. Implement the class + Street ----All Parameters-> +Freewayl --All Parameters--- country. Write the following + setter/getter > methods: + toString(): String + setter/getter a) A constructor to initialize roads. + toString(): String the name and create the arrayList b) The methods getNamel) and getRoads(). c) The coutStreets 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 speed Limit, a int length, and a boolean carpool. The code is below publlo class Road private int speed limit. Length private boolean carpool puble Rond tot speedlit, int length, boolean caipeal) this apeedlimit speelt: this. Length - length: this.carpool - carpool 2 - //Settere and gettes ao atsped here. Are they wiss ir you need any of the public string tooting) return "Road length.Length, speed limit is speed.imit " and carpool lane is - carpool ? "available.- 1 'not available.) 1 1 C! The Street class inherits from the class Road. The code is below: Page 4 of 5 public class Street extends Road private String name: public Street (String name, int speedlimit, int length, boolean carpool) super (speedtimit, length, carpool); this.name = name; ) public String getName() return names public void setName(String name) this.nance - name sovereide public String toString) return "This 13" + nano + " + super.toString(); st. 1 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 speedlimit, int length, boolean Carpool) super (apoodtimit, length, carpool), this.code - code: public int getcode () ceturn code: public void sotCode (int code) ( this.code - code: Overrido public string toitring() { ceturn "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 road 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
Get step-by-step solutions from verified subject matter experts
