In Python:
Design a class structure for a stationery store. Your design is
not restricted but must satisfy the followings.
The store sells books and pens. Please define an abstract class for
items. Each item has three properties. The buying price should be
private property, the selling price should be public property, and
the number of items available for sale in the store should be
protected property. The class has setter and getter methods for the
private property. It has an Abstract method called
“sell”.
Books and Pens are two subclasses of the abstract class defined
above. The Books class has several properties such as name, writer,
number of pages, and publisher. The Pens class also has several
additional properties: brand, purpose (write/paint), color, and
diameter. The "sell" method should get the number of items to be
sold as its argument. When it is called from a book object, the
"sell" method should display the name, writer, and price, the
number of items to be sold and the total amount on the same line if
there are enough books. When we call the "sell" method with a pen
object, it should display the brand, purpose, diameter, color and
price, number of items, and the total amount on the same line if
there are enough pens. In both cases, the "sell" method should
update the number of items property.
Create enough numbers of objects for the following tasks:
1. Write a function to
display all books available in the store. The writer, name, and the
number of available items are displayed on each line.
2. Write a function to
display all pens so that each pen's brand, color, and diameter are
shown on each line.
3. Write a code that
calls the two functions that you wrote to display the lists of
books and pens. Then write at least 6 examples to sell some books
and pens to demonstrate your classes/objects function
correctly.
In Python: Design a class structure for a stationery store. Your design is not restricted but must satisfy the following
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
In Python: Design a class structure for a stationery store. Your design is not restricted but must satisfy the following
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!