Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1)the primary code is in the pictures but I reached these 2 questions and didn't know how to solve them please can i have the

1)the primary code is in the pictures but I reached these 2 questions and didn't know how to solve them please can i have the written code for them please question 7 and 8:

7) Define a class for an article in the shopping cart with name InCart. This class shall have following members:

  • a private pointer attribute with name article to an object of class Article
  • a private integer attribute with name amount how many of this article are placed in the shopping cart.
  • a private attribute with name next of type pointer to InCart for building up a list.
  • a public constructor with three parameters to initialise the three attributes of an object; the amount shall be 0 as default parameter, the pointer to the next article in a shopping cart a null pointer also as default parameter.
  • a virtual public destructor outputting "~Incart()" and the amount as well as calling the destructor for the article (see examples at the bottom).
  • a public method with name get_next without parameters returning a pointer to the next article in shopping cart as function value.
  • a virtual public method with name print without parameters, outputting the amount, then sending message print to the article in the shopping cart, then in a new line outputting formatted as in the examples at the bottom the single gross price and the total gross price for the chosen amount of articles onto an output stream (see example at the bottom).
  1. Define a class for a shopping cart with name ShoppingCart. This class shall have following members:
  • a private pointer attribute with name articles to the head of a list of articles in the shopping cart of class InCart
  • three private real valued attributes with names minFressShipping for which purchase value free shipping is offered, sumNetPrice for the total net price sum of all articles in the shopping cart and sumGrossPrice for the total gross price sum.
  • a public standard constructor initialising an empty shopping cart with both sum values 0 EUR and the purchase value for free shipping with1000 EUR
  • a public destructor outputting "~ShoppingCart()" and afterwards deleting each article in the shopping cart starting with an output "delete article: " such that no memory leak will exist.
  • a public method with name set_minFreeShipping with one parameter assigning its value to the same named attribute.
  • a public method with name add_article with an amount and a pointer to an article as parameters, adding a new object InCart on heap to the shopping cart and actualising the two sum variables of the class appropriately.

a virtual public method with name print without parameters writing a shopping onto the standard output stream cart formatted as given in the examples at the bottom. Especially the net price sum, the tax (difference gross minus net total sum) and the gross price sum shall be outputted at the end of the shopping cart. Take care to also regard the (may be) shipping cost output of 5.90 EUR (see example at the bottom)!

code so far :

#include #include #include using namespace std; //ANSWER 1 class Article { private: string model; double netPrice; double taxRate; public: Article(string m, double n, double t=19) { model.assign(m); netPrice=n; taxRate=t; } virtual~Article() { cout

{ set_model(m); set_netPrice(n); original=o; } virtual ~Accessory() { cout

} }; //ANSWER 3 enum class OperatingSystem { unknown, android, iOS, macOS, linux, proprietary, unix, windows }; ostream& operator

image text in transcribed

Dokument2 - Word Suchen gen Oberprfen Ansicht Hilfe Bildformat 4536.40 EUR 861.92 EUR sum gross price: 5398.32 EUR shipping: 0.00 EUR total: 5398.32 POR Shopping Cart delete article: -Incart() 1 Botebook() -Device() Article() ASUS ROG SEX Scar III 6731 delete artielet -Incart 0 2 -Phone Device() -Article Apple 1 Phone 11 PEO 256GB delete articles - Incas () 1-Phone () -Device() -Article() Samsung Galaxy 510+ SM-G975F/DS Dual SIM delete articles - Incant) 3 -Accent Article() YOOLOX 10k Wireless Porrerbank L Shopping Cart - min Free Shipping - SumNetPrice - sumos.Price + Shopping Cart seminfree Shipping + add article + prin Article + got netPrice + grossPrice) gel modelo + modelo netPrice) print get next Operating System Accessory) Dokument2 - Word Suchen gen Oberprfen Ansicht Hilfe Bildformat 4536.40 EUR 861.92 EUR sum gross price: 5398.32 EUR shipping: 0.00 EUR total: 5398.32 POR Shopping Cart delete article: -Incart() 1 Botebook() -Device() Article() ASUS ROG SEX Scar III 6731 delete artielet -Incart 0 2 -Phone Device() -Article Apple 1 Phone 11 PEO 256GB delete articles - Incas () 1-Phone () -Device() -Article() Samsung Galaxy 510+ SM-G975F/DS Dual SIM delete articles - Incant) 3 -Accent Article() YOOLOX 10k Wireless Porrerbank L Shopping Cart - min Free Shipping - SumNetPrice - sumos.Price + Shopping Cart seminfree Shipping + add article + prin Article + got netPrice + grossPrice) gel modelo + modelo netPrice) print get next Operating System Accessory)

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

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions