[Solved] CS52 Assignment 5-OOP / Inheritance

30 $

File Name: CS52_Assignment_5-OOP_/_Inheritance.zip
File Size: 329.7 KB

SKU: [Solved] CS52 Assignment 5-OOP / Inheritance Category: Tag:

Or Upload Your Assignment Here:


Shopping Cart

Implement a program that tracks customers’ purchases. Create the following classes. Use appropriate access modifiers (instance variables should be private!) and data types for each. Don’t forget to add getter and setter functions.

  • Item: This class has the attributes (member variables) called title, description, and
    • Book: This class inherits from It has an instance variable called pageCount. o Movie: This class inherits from Item. It has an instance variable called length.
    • CD: This class inherits from It has an instance variable called trackCount.
  • ShoppingCart: This class keeps track of items that were You may limit the number of items in the cart. The cart should have functions to add an item and print the items currently in the cart to the console.
  • Customer: The customer class stores an id, the first name and the last name and a pointer to a shopping cart

Finally, implement a main function that creates a customer. Then add one item of each type to the customer’s shopping cart and list the items in the cart on the console.

Problem 2 Pizza

Implement a program that creates pizzas based on user order. First, create class called Ingredient with one instance variable description of type string which is set in the constructor and can be get using a getter function. Create the following classes that derive from Ingredient: TomatoSauce, Cheese, Dough, and Pepperoni; each with a constructor that passes the description argument to the base constructor. Use proper access modifiers!

Programming

Create a class Pizza which consists of a dynamically allocated array of Ingredient object pointers (a double pointer). The constructor expects the number of maximum ingredients as int which is used to dynamically allocate and initialize the array. Implement a destructor that deletes the Ingredient objects and the array. The class has a function void add(Ingredient* ingredient) which adds an ingredient to the pizza and a function to print its ingredients to the console.

Create an abstract class PizzaFactory with a pure virtual function called bake() that returns a

Pizza* object pointer. Create the two subclasses CheesePizzaFactory and

PepperoniPizzaFactory which both explicitly override the bake() function. Both functions should remain virtual. The CheesePizzaFactory instantiates Pizza and adds Dough, TomatoSauce, and Cheese to it. The PepperoniPizzaFactory creates a pizza and adds all ingredients including pepperoni to it.

Use the following main method which prompts a user to order a type of pizza and then instantiates the corresponding PizzaFactory for it. After the pizza is created by calling the bake() function, the ingredients of the pizza are printed by calling the listIngredients() function of the pizza object. Finally, the factory and the pizza objects are deleted.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CS52 Assignment 5-OOP / Inheritance
30 $