Question

In: Computer Science

Pycharm Complete the Place class that has the following attributes for place(name, country, priority and visited...

Pycharm

Complete the Place class that has the following attributes for place(name, country, priority and visited status) and the methods:

__init__

__str__

two methods to mark the place as unvisited\visited

Then in complete a list of Place objects in Places_Features class and the following methods.

load_places (from txt file into Place objects in the list)

save_places (from place list into output list)

add_place (add a place in the place list)

input.txt

Lima,Peru,3,n
Auckland,New Zealand,1,v
Rome,Italy,12,n

Can make the main.py give the following output

Output

* Lima in Peru priority 3
* Rome in Italy priority 12
Auckland in New Zealand priority 1
3 places. You still want to visit 2 places

Solutions

Expert Solution

class Place():
    def __init__(self,name,country,priority,visited_status):
        self.name = name
        self.country = country
        self.priority = priority
        self.visited_status = visited_status
    def __str__(self):
        if self.visited_status == 'n':
            return "* {} in {} priority {}".format(self.name,self.country,self.priority)
        return "{} in {} priority {}".format(self.name,self.country,self.priority)
    

class PlacesFeature():
    def __init__(self):
        self.place_list = []
        self.out_list = []
        
    def load_places(self,text_file_path = 'input.txt'):
        file = open(text_file_path, 'r')

        for line in file.readlines():
            
            fname = line.rstrip().split(',')
            self.place_list.append(fname)
        return self.place_list
            
    def save_places(self,name_given):
        for i in self.place_list:
            if i.name == name_given:
                self.outlist.append(i)
        return self.outlist
                
    def add_place(self, place):
        self.place_list = Placeplace
        return self.place_list
        

    
    
    
        
        

Related Solutions

1) Create a table “college” that has as attributes name, city name, state/province/region name, country name,...
1) Create a table “college” that has as attributes name, city name, state/province/region name, country name, and year in which the college was established as well as an ID as primary key. Insert records for 5 colleges of your choice, including one or more you have attended. 2) Create a table “student” that has as attributes first name, last names, and college ID for students, and insert the names of yourself and friends who attended one or more colleges together...
Write a class Car that contains the following attributes: The name of car The direction of...
Write a class Car that contains the following attributes: The name of car The direction of car (E, W, N, S) The position of car (from imaginary zero point) The class has the following member functions: A constructor to initialize the attributes. Turn function to change the direction of car to one step right side (e.g. if the direction is to E,it should be changed to S and so on.) Overload the Turn function to change the direction to any...
Implement a class Student, including the following attributes and methods: Two public attributes name(String) and score...
Implement a class Student, including the following attributes and methods: Two public attributes name(String) and score (int). A constructor expects a name as a parameter. A method getLevel to get the level(char) of the student. score level table: A: score >= 90 B: score >= 80 and < 90 C: score >= 60 and < 80 D: score < 60 Example:          Student student = new Student("Zack"); student.score = 10; student.getLevel(); // should be 'D'. student.score = 60; student.getLevel(); //...
Write a Python class to represent a Salik account. The account has three attributes, a name,...
Write a Python class to represent a Salik account. The account has three attributes, a name, id, and the balance. The balance is a private attribute. The class has extra functions to add to the balance and reduce the balance. Both, these functions should return the current balance and if the balance is below AED 50.0 print the message “Note: Balance Below 50”. Your class must work for the code given below. #Test myCar = SalikAccount() myCar.setName("John") myCar.setID("190300300333") myCar.setBal(20.0) yourCar...
Using JAVA Create a class Client. Your Client class should include the following attributes: Company Name...
Using JAVA Create a class Client. Your Client class should include the following attributes: Company Name (string) Company id (string) Billing address (string) Billing city (string) Billing state (string) Write a constructor to initialize the above Employee attributes. Create another class HourlyClient that inherits from the Client class.   HourClient must use the inherited parent class variables and add in hourlyRate and hoursBilled. Your Hourly Client class should contain a constructor that calls the constructor from the Client class to initialize...
Create a class Employee. Your Employee class should include the following attributes: First name (string) Last...
Create a class Employee. Your Employee class should include the following attributes: First name (string) Last name (string) Employee id (string) Employee home street address (string) Employee home city (string) Employee home state (string) Write a constructor to initialize the above Employee attributes. Create another class HourlyEmployee that inherits from the Employee class.   HourEmployee must use the inherited parent class variables and add in HourlyRate and HoursWorked. Your HourEmployee class should contain a constructor that calls the constructor from the...
Create a class Client. Your Client class should include the following attributes: Company Name (string) Company...
Create a class Client. Your Client class should include the following attributes: Company Name (string) Company id (string) Billing address (string) Billing city (string) Billing state (string) Write a constructor to initialize the above Employee attributes. Create another class HourlyClient that inherits from the Client class.   HourClient must use the inherited parent class variables and add in hourlyRate and hoursBilled. Your Hourly Client class should contain a constructor that calls the constructor from the Client class to initialize the common...
Consider a class Movie that information about a movie. The class has the following attributes: • ...
Consider a class Movie that information about a movie. The class has the following attributes: • The movie name • The MPAA rating (for example, G, PG, PG-13, R) • The number of people that have rated this movie as a 1 (Terrible) • The number of people that have rated this movie as a 2 (Bad) • The number of people that have rated this movie as a 3 (OK) • The number of people that have rated this...
Write a class named Person with data attributes for a person’s first name, last name, and...
Write a class named Person with data attributes for a person’s first name, last name, and telephone number. Next, write a class named Customer that is a subclass of the Person class. The Customer class should have a data attribute for a customer number and a Boolean data attribute indicating whether the customer wishes to be on a calling list. Demonstrate an instance of the Customer class in a simple program. Using python
Write a Class called Module with the following attributes: module code, module name, list of lecturers...
Write a Class called Module with the following attributes: module code, module name, list of lecturers for the module (some modules may have more than one lecturer – we only want to store their names), number of lecture hours, and module description. Create a parameterised (with parameters for all of the class attributes) and a non-parameterised constructor, and have the accessor and mutator methods for each attribute including a toString method. Write a class Student with the following attributes: student...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT