Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A constructor to initialize the name and create the arrayList roads . The methods getName() and getRoads(). The coutStreets method that returns the number of

image text in transcribed

  1. A constructor to initialize the name and create the arrayList roads.
  2. The methods getName() and getRoads().
  3. The coutStreets method that returns the number of streets in the array list.
  4. The searchForStreetmethod that takes as parameter the name of a street and returns the street object if found or null if not found.
  5. A toString method to return information about all data fields.

Write a client class (application) in which you:

  1. 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.
  2. Write code to display the number of streets in the country object.
  3. Write code display the information the country object.
  4. Test the searchForStreet method by reading a street name from the user and displaying its description if it is available.

Implement the class Country only. The code of the classes Road, Street and Freeway is provided below. Road - speed Limit: int - length: int - carpool: boolean + Road ----All Parameters----) + setters/getters +toString(): String Country -name: String roads: ArrayList + Countryname: String) + getName(): String + getRoads(): ArrayList + addRoader: Road): void + countStreets(): int + searchFor Street (streetName: String): Street + toString(): String WWWWW Street - name: String + Street (----All Parameters----) + setter/getter + toString(): String Freeway - code: int + Freeway ----All Parameters----) + setter/getter + toString(): String www

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions