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:

  1. A protected class variable called citiesNameLthat is a list containing the cities names in order.

  2. A protected class variable caleed cityC that is the count of cities in a country.

  3. A constructor that receives a list of lists represent the country and initializes an instance variable called countryMap that is a 2D array representing the cities and the distances between the cities. In addition, it initializes the cityC attribute.

  4. 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 to cityC. YOU ARE ASKED TO WRITE THE PSEUDOCODE BEFORE YOU IMPLEMENT THIS FUNCTION. SHOW THE PSEUDOCODE TO THE INSTRUCTOR BEFORE THE IMPLEMENTATION.

  5. A function called roadExists() that receives a tuple in the form (a,b) where a is the first city and b is the second city and returns Ture if there exists a road between a and b. Otherwise, it returns False.

  6. A function called constructRoad() that receives a tuple in the form (a,b,c) where a is the first city, b is the second city, and c is the distance between a and b. Update the countryMap according to the received information.

  7. A function called updateDistance() that receives a tuple in the form (a,b,c) where a is the first city, b is the second city, and c is the new distance. Update the distance between city a and city b to be c if and only if there exists a road between a and b. Print an appropriate message if there does not exist a road between a and b

    Write your PSEUDOCODE of fillCitiesNameL()function here.(Python)

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!