Question: create a ciass to store intormation about a street: Instance variables should include: the street name the length of the street ( in km )

create a ciass to store intormation about a street:
Instance variables should include:
the street name
the length of the street (in km)
the number of cars that travel the street per day
the condition of the street ("poor", "fair", or "good").
Write a constructor (), that takes four arguments corresponding to the instance variables and creates one Street instance.
Street Class
Step 2:
Add additional methods:
Should return a string with the Street information neatly-formatted, as in: Elm is 4.10km long, sees 3000 cars per day, and is in poor condition.
compare:
This method should compare one Street to another, with the Street the method is called on being compared to a second Street passed to a parameter.
Return True or False, indicating whether the first street needs repairs more urgently than the second.
Streets in "poor" condition need repairs more urgently than streets in "fair" condition, which need repairs more urgently than streets in "good" condition.
If the condition of two Streets is the same, the one with more traffic is given higher priority.
Street Class
Step 3:
Add a global constant COST_PER_KM =1400000, to represent how much it costs to repair each kilometer of road.
Examine the format of the file streetData.txt.
Add code to read streets from file, and create a list of Street objects.
(Print a list of all streets, to verify that you have read them correctly.)
Print a list of the streets in poor condition, and calculate the total cost of repairing all of them.
Step 4: Additional Practice
Modify the code that constructs the Street list, so that the Streets are ordered by priority in the list.
Do not use a sort() function. Write your own sort, or preferably, perform an ordered insert as you are reading streets from the txt file. (Make use of your compare method)
If you have $40 million to spend on repairs, which streets could be repaired?
 create a ciass to store intormation about a street: Instance variables

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!