Question: DataSet Class Add a class called DataSet. The class should have these attributes and methods: copyright attribute Create a class attribute called copyright, that starts

DataSet Class Add a class called DataSet. The class should have these attributes and methods: copyright attribute Create a class attribute called copyright, that starts out assigned to the string "No copyright has been set". Be sure to watch the "Class Attributes" video and understand the difference between a class attribute and an instance attribute. header property Our class will include an instance attribute self._header, which is a friendly message that will be printed along with the menu of options. We will need two methods to manage header property, a getter and a setter. The setter should check whether the proposed header is a string, and has length less than or equal to 30. If so, set the instance attribute self._header to the proposed header. Otherwise raise a ValueError exception and do not change self._header. The getter should simply return self._header. Be sure to use the @property and @header.setter decorators on these methods. Important: getters and setters never print anything to the console, and never ask the user to enter any values directly. Your functions should not contain any print() or input() fiunctions. __init__() method: The constructor, or __init__() method, should take a single string parameter named "header" which defaults to the empty string. The constructor should create a private instance attribute, self._data. self._data will eventually contain the actual Airbnb data that our application will use, but for now we will set it to None. self._header should be set to the value of the header parameter. We won't do this directly, though. We want to take advantage of the setter we have created, in case the user passes an illegal value. So set self.header = header. The setter may raise an exception, so be sure to catch the exception and set self._header to the empty string if the call fails. Note that our project code will not make use of the header parameter, so we will do some separate testing to make sure that if the user enters a valid header, it is stored correctly, and if the user enters an invalid header, the header is set to the empty string. Modifications to Existing Code menu() function Add a parameter dataset of type DataSet in the function signature for menu(). The air_bnb argument that you added in the main() function will be passed to this parameter. Access the copyright attribute of dataset to print your copyright notice once (not in the loop) Using the dataset object, print the header at the beginning of the loop in menu(), so it always shows before print_menu(). main() function Inside your main() function, do these steps in order: Set the copyright class attribute to a copyright message that includes your name. Make sure you are able to do this before creating your DataSet object. create an instance of DataSet called air_bnb, without passing any header. Create a loop in the main function to ask the user for a header until a valid header is entered. You have already written the code to check for a valid header, so don't duplicate that code here. Just make use of the fact that the setter you wrote will raise an exception when a bad header is entered. Keep asking until no exception is raised. Pass air_bnb as an argument in the call to menu() Unit Test In addition to running your program and posting sample code, create a simple unit test for the header and copyright properties: Repeatedly create objects of type DataSet. Using the property getter we created, check header to make sure this behaves when: The object is created with not header argument. In this case the header should default to the empty string. The object is created with a valid header argument. In this case the header should be set as requested. The object is created with an invalid header argument. In this case the header should default to the empty string. Using one of the objects you created, now test the setter. Verify that this behaves properly when: User provides a valid header. In this case the header should be changed. User provides an invalid header. In this case the header should not be changed. Be sure to include the code for your unit test in your homework submission. In my solution, I just created a function called unit_test() and included it in the same file. Sample Run There are two sample runs. The first shows the functioning of the unit test. The second shows the output of the running program in its current state. Your output can be different as long as it meets the criteria above.

DataSet Class Add a class called DataSet. The class should have these

Testing constructor with default parameter: Pass Testing constructor with valid header argument: Pass Testing constructor with invalid header argument: Pass Testing setter with valid assignment: Pass Testing setter with invalid assignment: Pass Setting DataSet.copyright = 'copyright Eric Reed Checking that I can access this using DataSet.copyright Pass Checking that I can access this after created a test object using test.copyright Pass Please enter your name: Eric Hi Eric, welcome to Foothill's database project. What is your home currency?GBP Enter a header for the menu: Welcome to the airBNB Database Testing constructor with default parameter: Pass Testing constructor with valid header argument: Pass Testing constructor with invalid header argument: Pass Testing setter with valid assignment: Pass Testing setter with invalid assignment: Pass Setting DataSet.copyright = 'copyright Eric Reed Checking that I can access this using DataSet.copyright Pass Checking that I can access this after created a test object using test.copyright Pass Please enter your name: Eric Hi Eric, welcome to Foothill's database project. What is your home currency?GBP Enter a header for the menu: Welcome to the airBNB Database

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!