Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this task single inheritance with static and dynamic binding shall be trained. For this a simple and extendable electronic shopping cart shall be programmed.

In this task single inheritance with static and dynamic binding shall be trained. For this a simple and extendable electronic shopping cart shall be programmed. As example articles smart phones, notebooks and accessories shall be ordered (due to clarity in the UML class diagram below data types, parameters and destructors are omitted.)

image text in transcribed

image text in transcribed

image text in transcribed

Subtask 9

To test write a main function placing some articles as new objects on the heap into an electronic shopping cart:

  • define a shopping cart object of type ShoppingCart using the standard constructor.
  • Send a message to this object that the articles get free shipping starting from 500 EUR.
  • Add to this shopping cart a new accessory article on heap with an amount of three powerbanks "YOOLOX 10k Wireless Powerbank Qi" with single net price 31.08 EUR being no original accessory.
  • Print the complete shopping cart (there are shipping costs).
  • Add to this shopping cart a new smart phone "Samsung Galaxy S10+ SM-G975F/DS Dual SIM" with net price 661.67 EUR, 8GB main memory size and Android OS operating system
  • Add to this shopping cart two new smart phones "Apple iPhone 11 Pro 256GB" with net price 1097.47 EUR, 4GB main memory size and iOS operating system.
  • Add to this shopping cart a new notebook "ASUS ROG Strix Scar III G731" with net price 1586.55 EUR, 16GB main memory size, "512GB SSD + 1TB SSHD" as drive and MS Windows operating system.
  • Print again the complete shopping cart (now there are no shipping costs).

With the end offunction main automatically the complete shopping cart object gets deleted; your program shall show the outputs of the destructor calls like in the example given below.

Example program run:

image text in transcribed

Article InCart Shopping Cart article next - netPrice - taxRate - model + amount articles + InCart() + get_next() + print() + Article() + get_netPrice) + get grossPrice) + get_model() + set_model() + set_netPrice() + printo - minFree Shipping - sumNetPrice - sumGrossPrice + Shopping Cart + set_min Free Shipping) + add_article) + print() Device - main_memory Accessory - original + Accessory + printi) Os > Operating System + Device() + get_os() + print) unknown android iOS macOS linux proprietary unix windows Phone Notebook + Phone() + print) - convertible - drive + Notebook) + is a convertible() + print) Beispiel Warenkorb/Example Shopping Cart Shopping Cart minFreeShipping: sumNetPrice: sumGrossPrice: articles: 500.00 4536.40 5398.32 :InCart In Cart :InCart :InCart article: article: amount: next: 1 article: amount: next: 2 article: amount: next: 1 amount: next: Article :Article Article Article Subtask 2 Subtask 1 Define an abstract base class for an offered article with name Article. This class shall have following members: Define a class with name Accessory derived from abstract class Article. This class shall have following members: . a private Boolean attribute with name original for an original accessory. a public constructor with three parameters for the article name, the net price and whether it is an original accessory with true as default parameter. The tax rate shall be automatically initialised by the default parameter of class constructor Article. a virtual public destructor producing an output "-Accessory0" at its call (see examples at the bottom). a virtual public method with name print without parameters writing the article name and "(original accessory)", if it is an original one (see examples at the bottom). a private string attribute with name model storing the article model name. two private real valued attributes with names netprice for the net price and taxRate storing the tax value in percent of the article. a public constructor with three parameters to initialise the attributes of an object; the tax rate shall be a default parameter with 19 %. a virtual public destructor producing an output "-Article()" at its call and the article model name (see examples below). a public method with name set.model assigning a string parameter to the model name attribute a public method with name set.netPrice assigning the double parameter to the net price attribute. a public method with name get model without parameters returning the model name as function value. a public method with name get.netPcise without parameters returning the net price as function value. a public method with name get.grossPrice without parameters returning the gross price (gross price = net price + tax) as function value. a pure virtual public method with name print without parameter or return value. . Subtask 3 Define a C++11 enumeration class with name Operating System and enumeration values unknown, android, iOS, macos, linux, proprietary, unix and windows. Define an overloaded output operator > Operating System + Device() + get_os() + print) unknown android iOS macOS linux proprietary unix windows Phone Notebook + Phone() + print) - convertible - drive + Notebook) + is a convertible() + print) Beispiel Warenkorb/Example Shopping Cart Shopping Cart minFreeShipping: sumNetPrice: sumGrossPrice: articles: 500.00 4536.40 5398.32 :InCart In Cart :InCart :InCart article: article: amount: next: 1 article: amount: next: 2 article: amount: next: 1 amount: next: Article :Article Article Article Subtask 2 Subtask 1 Define an abstract base class for an offered article with name Article. This class shall have following members: Define a class with name Accessory derived from abstract class Article. This class shall have following members: . a private Boolean attribute with name original for an original accessory. a public constructor with three parameters for the article name, the net price and whether it is an original accessory with true as default parameter. The tax rate shall be automatically initialised by the default parameter of class constructor Article. a virtual public destructor producing an output "-Accessory0" at its call (see examples at the bottom). a virtual public method with name print without parameters writing the article name and "(original accessory)", if it is an original one (see examples at the bottom). a private string attribute with name model storing the article model name. two private real valued attributes with names netprice for the net price and taxRate storing the tax value in percent of the article. a public constructor with three parameters to initialise the attributes of an object; the tax rate shall be a default parameter with 19 %. a virtual public destructor producing an output "-Article()" at its call and the article model name (see examples below). a public method with name set.model assigning a string parameter to the model name attribute a public method with name set.netPrice assigning the double parameter to the net price attribute. a public method with name get model without parameters returning the model name as function value. a public method with name get.netPcise without parameters returning the net price as function value. a public method with name get.grossPrice without parameters returning the gross price (gross price = net price + tax) as function value. a pure virtual public method with name print without parameter or return value. . Subtask 3 Define a C++11 enumeration class with name Operating System and enumeration values unknown, android, iOS, macos, linux, proprietary, unix and windows. Define an overloaded output operator

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

Discuss what you think economics is concerned with addressing

Answered: 1 week ago