Question: 6 0 . 0 0 Step 4 . Create new module named order.py 1 . Import the Person Class into the order.py module Before you
Step Create new module named order.py
Import the Person Class into the order.py module
Before you start writing the Order class, youll need to import the Person class from another
file or module where it is defined. This is necessary because we will use a Person object as
the owner of the order
import person
Define the Order Class and a Class Variable
Create a class named Order.
Inside the class, define a class variable ordercount and set it to This variable will
track the total number of orders created.
Define the Constructor init Method
Inside the class, define the init method. This is the constructor, which gets called
automatically whenever a new Order object is created.
The constructor should accept three parameters:
price: the price of the order.
name: the name of the order.
owner: a Person object that represents the owner of the order.
Inside the constructor:
Increment the ordercount class variable by each time a new order is created.
Store the price and name as private instance variables use double underscores like
price and name
Store the owner as an instance variable owner it doesnt need to be private but
should be managed carefully
Write Getter and Setter Methods for price
Write a getprice method that returns the value of price.
Write a setpriceprice method that updates the value of price.
Write Getter and Setter Methods for name
Write a getname method that returns the value of name.
Write a setnamename method that updates the value of name.
Write the displayInfo Method
Write a method called displayInfo to display information about the order.
Inside this method:
Print a separator line to make the output clearer.
Print the name and price of the order.
Call the displayInfo method of the owner the Person object to display the persons
information. You can use self.owner.displayInfo to access the persons info.
Output should look like this:
DisplayInfo Order
Name: Coffee
Name:
name: Albert Einstein money: $
Define the main Function
Write a main function that will be executed when the program runs.
Inside the main function:
Create a Person object using the Person class from the person module You will use
this person as the owner of the order.
Create an Order object, passing the price, name, and the Person object owner to the
constructor.
Call the displayInfo method of the Order object to display the order and owner details.
Ensure the Program Runs Correctly
At the bottom of your file, add the standard Python entry point:
if namemain:
main
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
