Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //main.cpp file
- #include"Problem1.h"
- Item::Item()
- {
- title = "null";
- description = "null";
- price = 0.0;
- }
- Item::Item(std::string passTitle, std::string passDescription, double passPrice)
- {
- title = passTitle;
- description = passDescription;
- price = passPrice;
- }
- std::string Item::getTitle()
- {
- return title;
- }
- std::string Item::getDescription()
- {
- return description;
- }
- double Item::getPrice()
- {
- return price;
- }
- void Item::setTitle(std::string x)
- {
- title = x;
- }
- void Item::setDescription(std::string x)
- {
- description = x;
- }
- void Item::setPrice(double x)
- {
- price = x;
- }
- Book::Book()
- {
- title = "null";
- description = "null";
- price = 0.0;
- pageCount = 0;
- }
- Book::Book(std::string passTitle, std::string passDescription, double passPrice, int passPageCount)
- {
- title = passTitle;
- description = passDescription;
- price = passPrice;
- pageCount = passPageCount;
- }
- int Book::getPageCount()
- {
- return pageCount;
- }
- void Book::setPagecount(int x)
- {
- pageCount = x;
- }
- void Book::print()
- {
- std::cout << "Book: " << title << " Price: $" << std::setprecision(2) << std::fixed << price << " " << description << " Pages: " << pageCount << std::endl;
- }
- Movie::Movie()
- {
- title = "null";
- description = "null";
- price = 0.0;
- length = 0;
- }
- Movie::Movie(std::string passTitle, std::string passDescription, double passPrice, int passLength)
- {
- title = passTitle;
- description = passDescription;
- price = passPrice;
- length = passLength;
- }
- int Movie::getLength()
- {
- return length;
- }
- void Movie::setLength(int x)
- {
- length = x;
- }
- void Movie::print()
- {
- std::cout << "Movie: " << title << " Price: $" << std::setprecision(2) << std::fixed << price << " " << description << " Length: " << length << " minutes" << std::endl;
- }
- CD::CD()
- {
- title = "null";
- description = "null";
- price = 0.0;
- trackCount = 0;
- }
- CD::CD(std::string passTitle, std::string passDescription, double passPrice, int passTrackCount)
- {
- title = passTitle;
- description = passDescription;
- price = passPrice;
- trackCount = passTrackCount;
- }
- int CD::getTrackCount()
- {
- return trackCount;
- }
- void CD::setTrackCount(int x)
- {
- trackCount = x;
- }
- void CD::print()
- {
- std::cout << "CD: " << title << " Price: $" << std::setprecision(2) << std::fixed << price << " " << description << " Track Count: " << trackCount << std::endl;
- }
- ShoppingCart::ShoppingCart(int x)
- {
- numItemsInCart = x;
- Item ** itemArray = new Item*[numItemsInCart];
- }
- ShoppingCart::ShoppingCart()
- {
- numItemsInCart = 1;
- Item ** itemArray = new Item*[numItemsInCart];
- }
- ShoppingCart::~ShoppingCart()
- {
- delete []itemArray;
- }
- void ShoppingCart::addItems()
- {
- int iterator = 0;
- int userChoice = -1;
- while (iterator < numItemsInCart)
- {
- std::cout << "Enter 1 to add a book, 2 to add a movie, or 3 to add a CD: ";
- std::cin >> userChoice;
- std::string userEnteredTitle, userEnteredDescription;
- double userEnteredPrice;
- std::cout << "Please Enter a title: ";
- std::getline(std::cin, userEnteredTitle);
- std::cout << "Please Enter a description: ";
- std::getline(std::cin, userEnteredDescription);
- std::cout << "Please Enter a price: ";
- std::cin >> userEnteredPrice;
- if (userChoice == 1)
- {
- int UserEnteredPageCount;
- std::cout<<"Please Enter a page count: ";
- std::cin >> UserEnteredPageCount;
- itemArray[iterator] = new Book(userEnteredTitle, userEnteredDescription, userEnteredPrice, UserEnteredPageCount);
- iterator++;
- }
- else if (userChoice == 2)
- {
- int movieLength;
- std::cout << "Please Enter movie length: ";
- std::cin >> movieLength;
- itemArray[iterator] = new Movie(userEnteredTitle, userEnteredDescription, userEnteredPrice, movieLength);
- iterator++;
- }
- else if (userChoice == 3)
- {
- int userEnteredTrackCount;
- std::cout << "Please Enter the number of tracks: ";
- std::cin >> userEnteredTrackCount;
- itemArray[iterator] = new CD(userEnteredTitle, userEnteredDescription, userEnteredPrice, userEnteredTrackCount);
- iterator++;
- }
- else
- {
- std::cout << "Please Enter a valid choice, either 1, 2, or 3" << std::endl;
- }
- }
- }
- void ShoppingCart::printItems()
- {
- //to be added
- }
- Customer::Customer()
- {
- userID = 0000;
- firstName = "null";
- lastName = "null";
- customerShoppingCart = new ShoppingCart(1);
- }
- Customer::Customer(std::string uFirstName, std::string uLastName, int numItems)
- {
- firstName = uFirstName;
- lastName = uLastName;
- customerShoppingCart = new ShoppingCart[numItems];
- }
- Customer::~Customer()
- {
- delete customerShoppingCart;
- }
- int main()
- {
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement