Question: Exercise 1 Define a class called country that includes the following attributes and functions: A protected class variable called citiesNameL that is a list containing
Exercise 1
Define a class called country that includes the following attributes and functions:
A protected class variable called
citiesNameLthat is a list containing the cities names in order.A protected class variable caleed
cityCthat is the count of cities in a country.A constructor that receives a list of lists represent the country and initializes an instance variable called
countryMapthat is a 2D array representing the cities and the distances between the cities. In addition, it initializes thecityCattribute.A function called
fillCitiesNameL()that reads the cities names from the user. Ensure that duplicated city name is not allowed and the number of cities should be equal tocityC. YOU ARE ASKED TO WRITE THE PSEUDOCODE BEFORE YOU IMPLEMENT THIS FUNCTION. SHOW THE PSEUDOCODE TO THE INSTRUCTOR BEFORE THE IMPLEMENTATION.A function called
roadExists()that receives a tuple in the form(a,b)whereais the first city andbis the second city and returnsTureif there exists a road betweenaandb. Otherwise, it returnsFalse.A function called
constructRoad()that receives a tuple in the form(a,b,c)whereais the first city,bis the second city, andcis the distance betweenaandb. Update thecountryMapaccording to the received information.-
A function called
updateDistance()that receives a tuple in the form(a,b,c)whereais the first city,bis the second city, andcis the new distance. Update the distance between cityaand citybto becif and only if there exists a road betweenaandb. Print an appropriate message if there does not exist a road betweenaandbWrite your PSEUDOCODE of
fillCitiesNameL()function here.(Python)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
