Step-1 Imagine a Car Parts and Accessories shop, which requires a software system to keep track of stock items and prices. The shop will sell different kinds of stock items. However, to start with, you have been tasked with designing and implementing a class called StockItem with the following properties. An instance (object) of the StockItem class represents a particular item which the shop sells, with a string representing fixed stock code, an integer representing variable quantity in stock and a double representing variable price of the stocked item. All these variables should be declared as private variables. The StockItemclass also contains a class variable (shared by all instances) of type string representing stock category which you can initialise as 'Car accessories'. A constructor that creates a Stock Item with the specified quantity, price and the stock code. All the appropriate ‘setters’ and ‘getters’ methods, including a getStockName() method which returns the string "Unknown Stock Name" and a getStockDescription() method which returns the string "Unknown Stock Description". An increaseStock() method that increases the stock level by the given amount. If the value is less than 1 or the stock exceeds 100, a suitable error message should be printed. A sellStock() method that attempts to reduce the stock level by the given amount. If it is less than 1, a suitable error message should be printed. If the amount is otherwise less than or equal to the stock level, then the reduction is successful and true is returned. Else there is no effect, but false is returned. A getVAT() method that returns the standard percentage VAT rate, e.g., you can use 17.5 Appropriate ‘setters’ method for price (without VAT) and ‘getters’ methods for price with and without VAT A method named __str__ () that returns a string giving the stock code, the stock name, the description, the quantity in stock, the price before VAT and the price after VAT. It must use the appropriate methods above to obtain the stock name, description, quantity and prices. Implement the above class and test it. You should create some instances of StockItem class, increase stock, sell some stock and change the price, whilst printing out the items in between. Step 2. The Car Parts and Accessories shop has got plenty of GeoVision Sat Nav navigation system at very competitive prices, which are going to be the first item on sale. You need to design and implement a class NavSys which is a sub-class of StockItem. You also need to create one new private instance variable of your NavSys class to represent navsys brand. A parameterised constructor of the NavSys class must call the StockItem’s constructor using super to initialise the super class’s instance variables. The NavSys class will override the instance methods getStockName() and getStockDescription() with ones that return "Navigation system" and " GeoVision Sat Nav" respectively. NavSys class will also override the __str__ () method using the concept of super in Python.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Step-1

Imagine a Car Parts and Accessories shop, which requires a software system to keep track of stock items and prices. The shop will sell different kinds of stock items. However, to start with, you have been tasked with designing and implementing a class called StockItem with the following properties.

  • An instance (object) of the StockItem class represents a particular item which the shop sells, with a string representing fixed stock code, an integer representing variable quantity in stock and a double representing variable price of the stocked item. All these variables should be declared as private variables. The StockItemclass also contains a class variable (shared by all instances) of type string representing stock category which you can initialise as 'Car accessories'.

  • A constructor that creates a Stock Item with the specified quantity, price and the stock code.

  • All the appropriate ‘setters’ and ‘getters’ methods, including a getStockName() method which returns the string "Unknown Stock Name" and a getStockDescription() method which returns the string "Unknown Stock Description".

  • An increaseStock() method that increases the stock level by the given amount. If the value is less than 1 or the stock exceeds 100, a suitable error message should be printed.

  • A sellStock() method that attempts to reduce the stock level by the given amount. If it is less than 1, a suitable error message should be printed. If the amount is otherwise less than or equal to the stock level, then the reduction is successful and true is returned. Else there is no effect, but false is returned.

  • A getVAT() method that returns the standard percentage VAT rate, e.g., you can use 17.5

  • Appropriate ‘setters’ method for price (without VAT) and ‘getters’ methods for price with and without VAT

  • A method named __str__ () that returns a string giving the stock code, the stock name, the description, the quantity in stock, the price before VAT and the price after VAT. It must use the appropriate methods above to obtain the stock name, description, quantity and prices.

  • Implement the above class and test it. You should create some instances of StockItem class, increase stock, sell some stock and change the price, whilst printing out the items in between.

    Step 2. The Car Parts and Accessories shop has got plenty of GeoVision Sat Nav navigation system at very competitive prices, which are going to be the first item on sale. You need to design and implement a class NavSys which is a sub-class of StockItem. You also need to create one new private instance variable of your NavSys class to represent navsys brand. A parameterised constructor of the NavSys class must call the StockItem’s constructor using super to initialise the super class’s instance variables. The NavSys class will override the instance methods getStockName() and getStockDescription() with ones that return "Navigation system" and " GeoVision Sat Nav" respectively. NavSys class will also override the __str__ () method using the concept of super in Python.

     

Task Specification-Step-1
Sample Run
An example run might be as follows.
Creating a stock with 10 units Unknown item, price 99.99 each,
and item code W101 Printing item stock information:
Stock Category: Car accessories
Stock Type: Unknown Stock Name
Description: Unknown Stock Description
StockCode: W101
Price Without VAT: 99.99
PriceWithVAT: 117.48
Total unit in stock: 10
Increasing 10 more units
Printing item stock information:
Stock Category: Car accessories
Stock Type: Unknown Stock Name
Description: Unknown Stock Description
StockCode: W101
Price Without VAT: 99.99
PriceWithVAT: 117.48
Total unit in stock: 20
Sold 2 units
Printing item stock information:
Stock Category: Car accessories
Stock Type: Unknown Stock Name
Description: Unknown Stock Description
StockCode: W101
PriceWithoutVAT: 99.99
PriceWithVAT: 117.48
Total unit in stock: 18
Set new price 100.99 per unit
Printing item stock information:
Stock Category: Car accessories
Stock Type: Unknown Stock Name
Description: Unknown Stock Description
StockCode: W101
Price Without VAT: 100.99
PriceWithVAT: 118.66
Total unit in stock: 18
Increasing 0 more units
The error was: Increased item must be au
Transcribed Image Text:Task Specification-Step-1 Sample Run An example run might be as follows. Creating a stock with 10 units Unknown item, price 99.99 each, and item code W101 Printing item stock information: Stock Category: Car accessories Stock Type: Unknown Stock Name Description: Unknown Stock Description StockCode: W101 Price Without VAT: 99.99 PriceWithVAT: 117.48 Total unit in stock: 10 Increasing 10 more units Printing item stock information: Stock Category: Car accessories Stock Type: Unknown Stock Name Description: Unknown Stock Description StockCode: W101 Price Without VAT: 99.99 PriceWithVAT: 117.48 Total unit in stock: 20 Sold 2 units Printing item stock information: Stock Category: Car accessories Stock Type: Unknown Stock Name Description: Unknown Stock Description StockCode: W101 PriceWithoutVAT: 99.99 PriceWithVAT: 117.48 Total unit in stock: 18 Set new price 100.99 per unit Printing item stock information: Stock Category: Car accessories Stock Type: Unknown Stock Name Description: Unknown Stock Description StockCode: W101 Price Without VAT: 100.99 PriceWithVAT: 118.66 Total unit in stock: 18 Increasing 0 more units The error was: Increased item must be au
Creating a stock with 10 units Navigation
system, price 99.99, item code NS101, and
brand TomTom Printing item stock
information:
Stock Category: Car accessories
Stock Type: Navigation system
Description: GeoVision Sat Nav
StockCode: NS101
PriceWithoutVAT: 99.99
PriceWithVAT: 117.48
Total unit in stock: 10
Brand: TomTom
Increasing 10 more units
Printing item stock information:
Stock Category: Car accessories
Stock Type: Navigation system
Description: GeoVision Sat Nav
StockCode: NS101
PriceWithout VAT: 99.99
PriceWithVAT: 117.48
Total unit in stock: 20
Brand: TomTom
Sold 2 units
Printing item stock information:
Stock Category: Car accessories
Stock Type: Navigation system
Description: GeoVision Sat Nav
StockCode: NS101
Price Without VAT: 99.99
Price WithVAT: 117.48
Total unit in stock: 18
Brand: TomTom
Set new price 100.99 per unit
Printing item stock information:
Stock Category: Car accessories
Stock Type: Navigation system
Description: GeoVision Sat Nav
StockCode: NS101
Price Without VAT: 100.99
PriceWithVAT: 118.66
Total unit in stock: 18
Brand: TomTom
Increasing 0 more units
The error was: Increased item must be
greater than or equal to one
Transcribed Image Text:Creating a stock with 10 units Navigation system, price 99.99, item code NS101, and brand TomTom Printing item stock information: Stock Category: Car accessories Stock Type: Navigation system Description: GeoVision Sat Nav StockCode: NS101 PriceWithoutVAT: 99.99 PriceWithVAT: 117.48 Total unit in stock: 10 Brand: TomTom Increasing 10 more units Printing item stock information: Stock Category: Car accessories Stock Type: Navigation system Description: GeoVision Sat Nav StockCode: NS101 PriceWithout VAT: 99.99 PriceWithVAT: 117.48 Total unit in stock: 20 Brand: TomTom Sold 2 units Printing item stock information: Stock Category: Car accessories Stock Type: Navigation system Description: GeoVision Sat Nav StockCode: NS101 Price Without VAT: 99.99 Price WithVAT: 117.48 Total unit in stock: 18 Brand: TomTom Set new price 100.99 per unit Printing item stock information: Stock Category: Car accessories Stock Type: Navigation system Description: GeoVision Sat Nav StockCode: NS101 Price Without VAT: 100.99 PriceWithVAT: 118.66 Total unit in stock: 18 Brand: TomTom Increasing 0 more units The error was: Increased item must be greater than or equal to one
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Software Development
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education