Question

Final PYTHON program: Create a home inventory class that will be used by a National Builder...

Final PYTHON program:
Create a home inventory class that will be used by a National Builder to maintain inventory of available houses in the country. The following attributes should be present in your home class:
-private int squarefeet
-private string address
-private string city
-private string state
-private int zipcode
-private string Modelname
-private string salestatus (sold, available, under contract)

Your program should have appropriate methods such as:
-constructor
-add a new home
-remove a home
-update home attributes

At the end of your program, be sure that it allows the user to output all home inventory to a text file.
Be sure that your final program includes your source code and screenshots of the application, executing the application, and the results.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Thanks for posting the question, Here are the two classes in python you will be needing. Home.py is a class that encapsulates all the instance variables and function a home can have. While HomeInventory.py encompases a list of Home object and operations on the individual Home.

Let me know for any questions and doubts, i'll be happy to assist you

_________________________________________________________________________________________________

class Home():

    homes=[]
    def __init__(self,sq_ft,address,city,state,zip,model,status):

        self._square_feet=sq_ft
        self._address=address
        self._city=city
        self._state=state
        self._zipcode=zip
        self._model=model
        self._status=status

    def get_home_size(self):
        return self._square_feet
    def get_home_address(self):
        return self._address
    def get_home_city(self):
        return self._city
    def get_home_state(self):
        return self._state
    def get_home_zipcode(self):
        return self._zipcode
    def get_home_model(self):
        return self._model
    def get_home_status(self):
        return self._status

    def set_home_size(self,sq_ft):
        self._square_feet=sq_ft
    def set_home_address(self,address):
        self._address=address
    def set_home_city(self,city):
        self._city=city
    def set_home_state(self,state):
        self._state=state
    def set_home_zipcode(self,zip):
        self._zipcode=zip
    def set_home_model(self,model):
        self._model=model
    def set_home_status(self,status):
        self._status=status

    def __str__(self):
        return str(self._square_feet)+","+str(self._address)+","+str(self._city)+","
               +str(self._state)+","+str(self._zipcode)+","+str(self._model)+","+str(self._status)

_________________________________________________________________________________________________

class HomeInventory():

    def __init__(self):
        self.home_list=[]

    def add_home(self,home):
        self.home_list.append(home)

    def remove_home(self,sq_ft,address,city,state,zip,model,status):

        home_to_be_deleted=None
        for home in self.home_list:
            if home.get_home_size()==sq_ft and 
                home.get_home_address()==address and 
                home.get_home_city()==city and 
                home.get_home_state()==state and 
                home.get_home_zipcode()==zip and 
                home.get_home_model()==model and 
                home.get_home_status()==status:
                home_to_be_deleted=home
                break
        self.home_list.pop(home_to_be_deleted)


    def update_home_attribute(self,home,attribute_name,attribute_value):

        if not home ==None:
            if attribute_name=='squarefeet':
                home.set_home_size(attribute_value)
            elif attribute_name=='address':
                home.set_home_address(attribute_value)
            elif attribute_name=='city':
                home.set_home_city(attribute_value)
            elif attribute_name=='state':
                home.set_home_state(attribute_value)
            elif attribute_name=='zip':
                home.set_home_zipcode(attribute_value)
            elif attribute_name=='model':
                home.set_home_model(attribute_value)
            elif attribute_name=='status':
                home.set_home_status(attribute_value)

    def export_to_file(self,file_path):
        try:
            with open(file_path,'w+') as write_file:
                for home in self.home_list:
                    write_file.write(home)
                    write_file.write('
')
        except:
            print('Error occurred while writing to file!')

_________________________________________________________________________________________________

thank you !

Add a comment
Know the answer?
Add Answer to:
Final PYTHON program: Create a home inventory class that will be used by a National Builder...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need this in java please Create an automobile class that will be used by a...

    I need this in java please Create an automobile class that will be used by a dealership as a vehicle inventory program. The following attributes should be present in your automobile class: private string make private string model private string color private int year private int mileage. Your program should have appropriate methods such as: default constructor parameterized constructor add a new vehicle method list vehicle information (return string array) remove a vehicle method update vehicle attributes method. All methods...

  • I NEED THIS PROGRAM COMPLETE WITH THE INPUT ALREADY IN IT. I HAVE NO TIME LEFT...

    I NEED THIS PROGRAM COMPLETE WITH THE INPUT ALREADY IN IT. I HAVE NO TIME LEFT TO GET IT DONE AND IT'S BEEN KICKING MY BEHIND FOR THE PAST FEW DAYS. THIS IS MY FINAL PROGRAM AND I HAVE NO CLUE ABOUT WHAT I'M DOING. SO, IF SOME WILL...WILL YOU PLEASE DO THE PROGRAM WITH THE INPUT ALREADY IN IT...I JUST WANT TO BE ABLE TO COPY PASTE AND RUN IT. I WOULD APPRECIATE IT A HECK OF A LOT....

  • 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 the Python code for a program adhering to the following specifications. Write an Employee class...

    Create the Python code for a program adhering to the following specifications. Write an Employee class that keeps data attributes for the following pieces of information: - Employee Name (a string) - Employee Number (a string) Make sure to create all the accessor, mutator, and __str__ methods for the object. Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: - Shift number (an integer,...

  • Respond to both of the following scenarios for Python programming. Scenario #1: A car dealership has...

    Respond to both of the following scenarios for Python programming. Scenario #1: A car dealership has hired your software development firm to create a new car inventory program. You first need to develop a class that represents the inventory of the dealership. What components and attributes will need to be included in your automobile class? Why? Scenario #2: A national builder has hired your software development firm to create a home inventory program. You first need to develop a class...

  • Help with StringAnalysis Write a WidgetViewer application. Create a class StringAnalysis. This class has an event...

    Help with StringAnalysis Write a WidgetViewer application. Create a class StringAnalysis. This class has an event handler inner that extends WidgetViewerActionEvent it has instance variables StringSet sSet JTextField inputStr JLabel numStr JLabel numChar In the constructor, create a WidgetViewer object create sSet create a local variable JLabel prompt initialized to "Enter a String" create inputStr with some number of columns create a local variable JButton pushMe initialized to "Push to include String" create numStr initialized to "Number of Strings: 0"...

  • Create a class House with the private fields: numberOfUnits of the type int, yearBuilt of the...

    Create a class House with the private fields: numberOfUnits of the type int, yearBuilt of the type int, assessedPrice of the type double. A constructor for this class should have three arguments for initializing these fields. Add accessors and mutators for all fields except a mutator for yearBuilt, and the method toString. Create a class StreetHouse which extends House and has additional fields: streetNumber of the type int, homeowner of the type String, and two neighbors: leftNeighbor and rightNeighbor, both...

  • 9.12 Ch 9 Program: The Evil Register Python 3.7 "The ItemToPurchase class If you haven't done so already, make s...

    9.12 Ch 9 Program: The Evil Register Python 3.7"The ItemToPurchase classIf you haven't done so already, make sure to complete zyLab 9.11 before this one. Otherwise, you will have to implement the ItemToPurchase class from scratch and this zyLab won't make much sense".ItemToPurchase class from zyLab 9.11 refers to:(1) Build the ItemToPurchase class with the following specifications:Attributes (3 pts)item_name (string)item_price (int)item_quantity (int)Default constructor (1 pt)Initializes item's name = "none", item's price = 0, item's quantity = 0Methodprint_item_cost()

  • Using Python you will create a simple class pet which will contain: Type of pet (a...

    Using Python you will create a simple class pet which will contain: Type of pet (a string) Name of pet(a string) Age of pet (an int) Tricks (a list of tricks the pet can perform) Fleas of pet (an int) All of these data attributes except for the last one (fleas) will be unique to each object. The fleas will be common to all pets, as they like to travel. In your main part of your program, you will create...

  • Create a Python file (book.py) that has a class named Book. Book class has four attributes,...

    Create a Python file (book.py) that has a class named Book. Book class has four attributes, title (string), author(string), isbn(string), and year(int). Title - the name of the book. Author - the name of the persons who wrote the book. ISBN - is a unique 13 digit commercial book identifier. Year - the year the title was printed. Your class should have the following methods: (1) __init__(self, title, author, isbn, year): This method called when an object (book) is created...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT