Uploaded by Mohammad Nasrallah

CSCI300L Sample final exam

advertisement
Given the following UML diagram:
Part 1: Implement the following classes: Note that some roads have a carpool lane which is restricted for
peak travel times or longer for the use of vehicles with a driver and one or more passengers.
Country
- name: String
- roads: ArrayList
+ Country(name: String)
+ getName(): String
+ addFreeway(f: Freeway): void
+ addStreet(s: Street): void
+ getRoads(): ArrayList
+ countStreets(): int
+ countFreewaysWithCarpool(): int
+ searchForStreet((streetName: String): Street
+ toString(): String
Road
- speedLimit: int
- length: int
- carpool: boolean
+ Road(----All Parameters----)
+ setters/getters
+toString(): String
Street
- name: String
+ Street (----All Parameters----)
+ setter/getter
+ toString(): String
Freeway
- code: int
+ Freeway(----All Parameters----)
+ setter/getter
+ toString(): String
Part 2: Implement a driver class (main class) as follows:
1.
2.
3.
4.
5.
Create a country object with name read from the user.
Add to the country object some freeways and streets as many as the user wants
Display the number of streets in the country object using the corresponding method in the Country class.
Count the freeways which have a carpool lane using the corresponding method in the Country class.
Test the searchForStreet method by reading a street name from the user and displaying its description if it is
available.
6. Display the description of all streets only.
Related documents
Download