Reduced to focus on polymorphism and templates

Assignment Help C/C++ Programming
Reference no: EM131174855

Object Oriented Development

Introduction 

This assignment follows the same application as the first three assignments where we examined  the problem of managing the accounts and inventory for a bookstore. In this assignment, we  focus on different types of inventory and you are required to develop a solution using the C++ language that has the following features:

Handles different types of inventory;

Record the Purchases and Sales based on the type of item and an assigned mark-up;

And

Uses a pointer array of inventory to store the different items in.

Requirements

This assignment requires you to write C++ code to implement four classes

Note that while some of these classes are related to those developed in the second assignments, the functionality of those assignments has been significantly reduced to focus  on polymorphism and templates, e.g., both SalesRegister and Publisher classes are  emoved.

The classes you must develop are:

A Template SimpleList class:

The SimpleList class must have the following features:

o Attribute/s to store the constant array pointer list of the Inventory objects and the count to keep track current element.

o Accessor and/or manipulator methods where appropriate

o AddElement function will check to make sure the current item is not reached the size before adding the parameter object on to the arraylist

o A constructor to initialise the Simple Item array list object

o A Print() has an output operator to format appropriately the data stored on the simple lis (sensible field widths should be used).

o A GetCount() return the current number of item on the array

o A GetItem(int position) return the item element on the array list at the parameter position.

An Inventory class:

This is an abstract class which has 4 pure virtual functions:

o A GetItemData() function allows to prompt user for the item details ;

o A RecordSales() function will update the sold quantity for the inventory if the stock is higher  or equal to the sold quantity parameter;

o A RecordPurchase() function will update the purchase quantity for the inventory by the sold  quantity parameter;

o A Print() function display the inventory item details and purchased and sold information

A StockItem class is inherited from the Inventory class:

Has cost price, mark-up, sold quantity and purchase quantity attributes;

Has a custom constructor, accessor and mutator functions for the above description attributes;  and

And four other virtual functions to implement the RecordSales() and throw exception if there is not enough stock for the transaction record, GetData(), RecordPurchase() and Print() which described in the Inventory class. A GeneralItem class is inherited from the StockItem class :

Has the item description attribute;

The GetData() function will prompt the user to input the item description attribute and the markup attribute from the StockItem;

Has a custom constructor, accessor and mutator functions for the above description attributes; and

And the Print() display description attributes and all StockItem details.

A BookItem class is inherited from the GeneralItem class :

Has the extra Book Author, Publisher and Year attributes;

The GetData() function will prompt the user to input the author, publisher, year details and the markup attribute from the StockItem;

Has a custom constructor, accessor and mutator functions for the above description attributes; and

And the Print() display described attributes and all StockItem details.

THE INVENTORY SYSTEM UML

Inventory {abstract}

BookItem

StockItem

Provided Code - main()

#include <stdio.h>

#include <iomanip>

#include <iostream>

#include <string>

using namespace std;

#include "Inventory.h"

#include "StockItem.h"

#include "GeneralItem.h"

#include "BookItem.h"

#include "SimpleList.h"

#define SIZE 5

void menu()

{

int choice;

cout << "1. Add record\n";

cout << "2. Record Purchase\n";

cout << "3. Record Sale\n";

cout << "4. Print\n";

cout << "5. Exit\n";

cout << "Option? ";

cin >> choice;

if( choice < 1 || choice > SIZE)

throw(string("Invalid choice"));

else throw(choice);

}

int main()

{

// Inventory *list[SIZE];

SimpleList<Inventory, SIZE> list;

int cont = 1;

while(cont)

{

try

{

menu();

}

catch(string msg)

{

cout << msg << "\n";

}

catch(int i)

{

int type;

int qty;

float price;

Inventory* item;

switch(i)

{

case 1:

if( list.GetCount() < SIZE)

{

cout << "1. Book Item 2. General Item: ";

cin >> type;

if(type == 1) item = new BookItem;

else item = new GeneralItem;

item->GetData();

list.AddElement(item);

}

else cout << "Over Load\n";

break;

case 2:

if( list.GetCount() == 0) cout << "No Inventory\n";

else

{

for(type = 0; type < list.GetCount(); type++) // list data

{

cout << "List [" << type+1 << "]:\n";

list.GetItem(type)->Print();

}

do

{

cout << "Which List Purchase? ";

cin >> type;

} while(type < 0 || type > list.GetCount());

cout << "Purchase Qty: ";

cin >> qty;

cout << "Cost Price: ";

cin >> price;

item = (Inventory*) list.GetItem(type-1);

item->RecordPurchase(qty, price);

}

break;

case 3:

if( list.GetCount() == 0) cout << "No Inventory\n";

else

{

for(type = 0; type < list.GetCount(); type++)

{

cout << "List [" << type+1 << "]:\n";

list.GetItem(type)->Print();

}

do

{

cout << "Which List Sold? ";

cin >> type;

} while(type < 0 || type > list.GetCount());

cout << "Sold Qty: ";

cin >> qty;

try

{

item = (Inventory*) list.GetItem(type-1);

item->RecordSell(qty);

}

catch(string msg) { cout << msg << "\n"; }

}

break;

case 4:

if( list.GetCount() == 0) cout << "No Inventory\n";

else list.Print();

/* replace the loop to display the Inventory items

{

for(type = 0; type < list.GetCount(); type++)

{

cout << "List [" << type+1 << "]:\n";

list.GetItem(type)->Print();

}

} */

break;

case 5:

for(type = 0; type < list.GetCount(); type++) delete list.GetItem(type);

cont = 0;

break;

default: return 0;

} // end switch

} // end catch

} // end while

return 0;

}

Your assignment must also satisfy the following requirements:

You must use polymorphism in your solution to record the sales, purchases, get data and print functions;

You do not need to consider exceptions for this assignment (they will return in the final assignment);

Tabs (\t) can be used for formatting purposes;

You must use the main() function, above. Note that not all functions required above may be invoked by the provided main(); and

All floating point data should be displayed to two decimal places. For information on how to set the number of decimal places, see the Manipulators Session 1 pp9 Study Guide. You do not need to restore the number of decimal places.

Attachment:- Ass4_C,C++.rar

Reference no: EM131174855

Questions Cloud

Formal organizational structure : Apart from its formal organizational structure, in what ways can the global campany ensure that it is responding to the market and achieving efficiently, local responsiveness. and global learning?
General overview of how the project is proceeding : Initial greeting of thanks to your supervisor for being collaborative and supportive. General overview of how the project is proceeding. Operational successes. Description of a new festival activity. Description of challenges and problems confronting..
Who are affected during the second-round multiplier : Participate in a discussion with your classmates regarding the expenditure multiplier effect within your local community, state, or region which magnifies or multiplies expenditures that increase the real GDP. Describe who benefits from the first-rou..
Ayurvedic treatment for bursitis : Write an essay on the given topic "Ayurvedic treatment for Bursitis"
Reduced to focus on polymorphism and templates : the functionality of those assignments has been significantly reduced to focus  on polymorphism and templates, e.g., both SalesRegister and Publisher classes are  emoved.
Our economy is positioned within its business cycle : Participate in a discussion with your classmates regarding where you see the U.S. economy in its business cycle right now, as based on the economic concepts in the textbook. Now that we learned that the real business cycle results from fluctuations i..
The residents of the town ectenia all love economics : The residents of the town Ectenia all love economics, and the mayor proposes building an economics museum. The museum has a fixed cost of $2,400,000 and no variable costs. There are 100,000 town residents, and each has the same demand for museum visi..
When gasoline prices were at an all-time high : Cost Planning; Gasoline Prices In June 2008, when gasoline prices were at an all-time high, greater than $4 per gallon, Chrysler Motor Company promoted its Jeep vehicle with the offer of either $4,500 off the price of the vehicle or the guarantee tha..
How does australian culture compare to other world culture : How does the Australian culture compare to other world cultures (eg. Your home country or other countries that you have visited)? Do you agree with the survey results for the Australian culture? Why or why not

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Reverses the characters in a character array

Write the function reverseit that reverses the characters in a character array. You must also write main that calls reverseit.

  Write in c++. read an inputfile.txt

write in C++.  read an inputFile.txt which contains integers that are virutal addresses, and I am suppossed to translate that into physical addresses using a page table and a transition lookaside buffer

  Write a menu-driven c program

Write a menu-driven C program with appropriate functions that allows the user to fill an array of 50 integers with random numbers on the range 1...999, inclusive, sort it, and then find search it to determine if a given random number was generated..

  Demonstrate overriding of their getter and setter methods

Organize following animals using classes and virtual function. tigers,crocodile, elephants,pythons,zebras,hawks, chickens,rabbits using at least 3 properties some of the animals share. demonstrate overriding of their getter and setter methods.

  Calculate the score percentage

If the input value within the valid range, the program will display a "good score" message; otherwise, the program will display an error message and then terminate the program. The program will then calculate the score percentage and then determin..

  What is the expected cost of the search

You are trying to locate a stolen car using a helicopter. The helicopter costs $350 per hour to rent. The number of hours to find the car follows a discrete uniform random variable with a = 3 and b =11. What is the expected cost of the search?

  Program that compares the number of possible sequences

Write a c++ program that compares the number of possible sequences of the length L that can be generated. The program must output a formatted list comparing the number of possible sequences for L=5,6,7,8,9. given size N=9

  Output of the given c++ code

What is the output of the given C++ code - You need to find out the output of the given code.

  Suggest an application system which is able to perform some

suggest an application system which is able to perform some arithmetic computations like commission system encryption

  Create a coke machine program in c++

We will start by having the users insert their money. Since they can not physically insert the money, we will just ask them how much they wish to insert and we will keep track of how much money they have inserted.

  Software and system standards

Describe system and software standards that could be used for the description of control constructs in C, C#, or Java.

  Recognize a string typed in as a valid or invalid

Use regex to recognize valid Social Security numbers.  A valid Social Security number consists of three digits, an optional hyphen, two digits, an optional hyphen, and four digits.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd