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.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
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.

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY