c++ 2) Design a class called LineItem that has the following member variables: .
ID: 3734866 • Letter: C
Question
c++
2) Design a class called LineItem that has the following member variables: . prod. A Product object. quantity. An integer variable that holds the quantity. The class should have the following member functions: .A default constructor that assigns 0 to the quantity variable. A constructor that accepts the following as arguments and assign them to the appropriate member variables: a product object and a quantity . getTotalPrice: Returns the total price (Computes the total cost of this line item) .print: Prints the line item. It prints the description of the product, the price of the product, the quantity, and the total price of the line item the information as in the following screenshot. Enter the description of your iten: 16GB White Snartphone Enter the price of your iten: 570.00 Enter the quantity: Description Price Quant itgTota285.0e 570.80 16GB White Snartphone Press any key to continue.. Good Luck!Explanation / Answer
Hi friend, You have not posted the description of "Product" class, so i do not know the details about this class.
So i can not fully implement LineItem class.
I have implemented all possible from given information:
#include <iostream>
using namespace std;
class LineItem{
private:
Product prod;
int quantity;
public:
LineItem() {
quantity = 0;
}
LineItem(Product p, int q) {
prod = p;
quantity = q;
}
double getTotalPrice() {
//
}
void print() {
//
}
};
int main() {
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.