//here is the skeleton//
#include
#include
#include
using namespace std;
class order_record
{
public:
string pname;
string cname;
double plant_cost;
int quantity;
double tax_rate;
double net_cost;
double discount_rate;
double discount;
double purchase_tax;
double total_cost;
};
class order_class
{
public:
order_class();
order_class(const order_class& org); //copy constructor
~order_class(); //de-allocates all memory allocate to STR by operator new.
bool is_Empty(); //inline implementation
bool is_full();//inline implementation
int search(const string key);//returns location of key if in STR; otherwise return -1
void add( ); //adds a order record to STR
order_class & operator-(const string key); //removes all items in STR with a plant name that matches key.
void double_size();
void process();
friend ostream& operator
private:
int count;
int size;
order_record *STR;
};
/************************************************************************************************************************************/
//Name: default constructor
//Precondition:
//Postcondition:
//Decription: Reads the data file of purchase order information (plant name, county name, plant cost and quantity) into the dynamic array of order records,
//STR. If the count become equal to the size the function double_size is called and the memory allocated to STR is doubled.
/************************************************************************************************************************************/
order_class::order_class()
{
cout
}
/************************************************************************************************************************************/
//Name: copy constructor
//Precondition:
//Postcondition:
//Description: The function performs a deep copy of the formal parameter org.
//
/************************************************************************************************************************************/
order_class::order_class(const order_class& org)
{
}
/***********************************************************************************************************************************/
//Name: is_Empty
//Precondition:
//Postcondition:
//Decription: returns true if STR is empty
/**********************************************************************************************************************************/
bool order_class::is_Empty()
{
return count == 0;
}
/**********************************************************************************************************************************/
//Name: is_full
//Precondition:
//Postcondition:
//Decription: returns true if STR is full
/*********************************************************************************************************************************/
bool order_class::is_full()
{
return count == size;
}
/**********************************************************************************************************************************/
//Name: search
//Precondition:
//Postcondition:
//Decription: locates key in STR if it is there; otherwise -1 is returned
/*********************************************************************************************************************************/
int order_class::search(const string key)
{
return -1;
}
/*********************************************************************************************************************************/
//Name: add
//Precondition:
//Postcondition:
//Decription: adds a order_record to STR; if STR is full, double_size is called to increase the size of STR. The user
// is prompted to enter the plant name, county name, plant cost and quantity.
/********************************************************************************************************************************/
void order_class::add( )
{
}
/********************************************************************************************************************************/
//Name: operator-
//Precondition:
//Postcondition:
//Decription: removes all order records in STR with a plant name field that matches key, if it is there.
/*******************************************************************************************************************************/
order_class& order_class::operator-(const string key)
{
return *this; //returning the current object
}
/******************************************************************************************************************************/
//Name: double_size
//Precondition:
//Postcondition:
//Decription: doubles the size (capacity) of STR
/******************************************************************************************************************************/
void order_class::double_size( )
{
size *=2;
order_record *temp = new order_record[size];
for(int i=0; i
{
temp[i] = STR[i];
}
delete [ ] STR;
STR = temp;
}
/******************************************************************************************************************************/
//Name: process
//Precondition:
//Postcondition:
//Decription: calculate the net cost, tax rate, order tax, discount and total cost for every order record in STR. for every call record in STR.
/*****************************************************************************************************************************/
void order_class::process()
{
}
/****************************************************************************************************************************/
//Name: operator
//Precondition:
//Postcondition:
//Decription: prints every field of every call_record in STR formatted to a file and return the stream.
/***************************************************************************************************************************/
ostream& operator
{
static int run = 1;
//put code here for the loop to print the data in the array to the stream out.
out
out
out
run++;
return out;//returning object that invoked the function
}
/****************************************************************************************************************************/
//Name: destructor
//Precondition:
//Postcondition:
//Decription: de-allocates all memory allocated to STR. This will be the last function to be called (automatically by the compiler)
//before the program is exited.
/***************************************************************************************************************************/
order_class::~order_class()
{
cout
}
//Here is your driver to test the program
int main()
{
order_class myOrders;//declaring order_class object myOrders; the default constructor is called automically.
cout
//Test 1:
cout
myOrders.process();
cout
cout
cout
cout
//Test 2:
//void add();
cout
myOrders.add();//test case: pname = rose, cname = dade, plant cost = 1, quantity = 1
cout
cout
cout
cout
//Test 3:
//operator-(string key);
cout
cout
myOrders -"rose";
cout
cout
myOrders - "bergenia" - "yarrow";
cout
cout
myOrders -"rose";
cout
cout
cout
cout
//Test 4:
//copy constructor
cout
order_class yourOrders = myOrders;
cout
cout
cout
cout
//Test 5:
//destructor will be invoked when object myOrders goes out of scope
cout
cout
cout
cout
return 0;
}
This assignment is an extension of Programming Assignment 10 (Module 11s Programming Assignment). You will implement class called order_class. The class will manage a dynamic array of purchase order records. Called the program (driver) for this assignment "nursery_porder11.cpp". You must separate the declaration and implementation for the class order_class. Put the declaration in the file called order_class.h, and put the class implementation in the file called order_class.cpp. However, you will need to modify the driver to test the functionality of your program. I have provided a driver skeleton to help you implement this program.
COP3014-Foundations of Computer Science Assignment #11 Objectives: 1. Separate class code into a declaration (header) and implementation components; 2. Implement a copy constructor; 3. Use the preprocessor directives #ifdef, #define, and #endif; This assignment is an extension of Programming Assignment 10 (Module 1l's Programming Assignment). You will implement class called "order_class". The class will manage a dynamic array of purchase order records. Called the program for this assignment "nursery_orders11.cpp". You must separate the declaration and implementation for the class "order_class". Put the declaration in the file called "order_class.h", and put the class implementation in the file called "order_class.cpp". However, you will need to modify the driver to test the functionality of your program. I have provided a skeleton (driver) of "nursery_ordersll.cpp" to help you implement this program Your input data will be in the file nursery_stock.txt". The descriptions of the functions you will implement are as follows: 1. The copy constructor will perform a deep copy of the an object; 2. (You implemented this function in the previous program.) The default constructor to initialize the state of your class. The default constructor will read the data from the file "nursery_stock.txt" into the dynamic array STR. If STR becomes full, the function should call the function "double_size" to double the size (capacity) of STR. Remember, count, size, and STR are private members of your class and do not need to be passed to a member function of your class. 3. (You implemented this function in the previous program.) is_Empty is a Boolean public member function of the class. It has no formal parameters because count is a member of the state of the class (private member) and does not need to be passed to it because the state of the class is known to all member functions of the class. If count=0 then true is returned; otherwise false is returned. 4. (You implemented this function in the previous program.) is Full is a Boolean public member function of the class. It has no formal parameters because count and size are members of the state of the class (private members) and they do not need to be passed to it because the state of the class is known to all member functions of the class. If count== size then true is return; otherwise false. The size is the capacity which is the total number of cells allocated to STR. 5. (You implemented this function in the previous program.) search is an integer public member function that has only one formal parameter, the key key is the plant name for the record you are searching for. The array of records, STR and count are members of the state of the class and do not need to be passed to a member function of the class; The function will return the location of key in STR if it is there; otherwise -1 is returned. 6. (You implemented this function in the previous program.) add is a void public member function that inserts information for an order record into STR. Duplicates plant names are okay; add will prompt the user for the plant name (pname), county name (cname), plant cost (plant_cost), and the quantity (quantity). You may call process record to re- process STR when you add a new record. add has no formal parameters. Remember, to call the function double_size if STR is full before you add a new order record. 7. (You implemented this function in the previous program.) Overload the operator"- " as member function of order_class with chaining. This function will have the same functionality as the "remove function from the previous assignment. Recall the following about the function remove: "remove is a public member function that deletes all records with the plant name that matches the value stored in key. If duplicate records exist with the same plant name they must all be deleted. "remove has only one formal parameter, the key." Note, because we are overloading with chaining we must return the current object "*this. 8. (You implemented this function in the previous program.) double_size is a void public member function that doubles the size (capacity) of STR. "double_size" has no formal parameters because size, count and STR are all members of the state of the class, order_class. First, size is multipled by two; second, memory is allocated using the statement order_record *temp = new order_record[size]; third the records in STR are copied into temp with the statement "temp[i]=STR[i] using a for loop. Forth, the old memory for STR is de-allocated using "delete [ ] STR"; Finally, STR is set to point to the new memory pointed to by temp using "STR = temp". 9. (You implemented this function in the previous program.) process has no formal parameters because they are already declared in the state of the class. The function will calculate the net cost of the purchase (net_cost), the tax rate (tax rate), the tax on the purchase (purchase_tax), the discount rate (discount_rate), the discount on the purchase (discount), and the total cost (total_cost). Please consider the following information to help you implement the necessary calculations: a. The tax rate (in percent) on a purchase is based on the county where the purchase was made. If the county was dade, the tax rate is 5.5%; if the count is broward, the tax rate is 5%; if the county was palm, the tax rate is 6%. b. The net cost of an order (net_cost), which does not include tax, is calculated by the following: net_cost = (quantity x plant_cost) c. The discount is based on the quantity of plants in the purchase. The discount is determined as follows: If quantity equals 0, then the discount percentage is 0% of the net cost; If I60 then discount percentage is 14%; . Note: Apply discount percentage after the net cost has been calculate discount = net_cost * (discount_percentage)/100; (drop / 100 if you converted the discount_percentage to a decimal) d. The tax on a purchase order_tax) is calculated by the following formula: purchase_tax = (net_cost* tax_rate/100 (drop/100 if you converted the rate from a percentage) e. The total cost of a purchase (rounded to the nearest hundredth) is calculated by the following formula: total_cost = net_cost + purchase_tax - discount. Note: All tax and cost calculations should be rounded to the nearest hundredths. as 10.(You implemented this function in the previous program.) Overload operator ""to your #include statements in your source file. Add "#include
" to your #include statement in your source file. Add #include " all formatting of output 4. Copy of Nursery_stock.txt: owl dade 10.55 100 hibiscus broward 15.82 15 rose dade 9.99 45 carnation palm 7.99 32 rose palm 7.99 60 widow palm 25.75 5 carnation dade 12.55 10 carnation dade 12.55 8 lilly broward 6.92 150 xerabtgemum palm 13.63 50 yarrow dade 22.85 20 zenobia palm 37.19 32 zephyranthes broward 62.82 40 daisy broward 15.99 80 aconitum dade 30.02 72 amaryllis dade 16.14 65 bogonia broward 18.45 3 bellflowbroward 2.96 200 bergenia palm 85.92 10 COP3014-Foundations of Computer Science Assignment #11 Objectives: 1. Separate class code into a declaration (header) and implementation components; 2. Implement a copy constructor; 3. Use the preprocessor directives #ifdef, #define, and #endif; This assignment is an extension of Programming Assignment 10 (Module Il's Programming Assignment). You will implement class called "order_class". The class will manage a dynamic array of purchase order records. Called the program for this assignment "nursery_orders 1.epp". You must separate the declaration and implementation for the class "order_class". Put the declaration in the file called "order_class.h", and put the class implementation in the file called "order_class.cpp". However, you will need to modify the driver to test the functionality of your program. I have provided a skeleton (driver) of "nursery_orders1.cpp" to help you implement this program. Your input data will be in the file-nursery_stock.txt". The descriptions of the functions you will implement are as follows: 1. The copy constructor will perform a deep copy of the an object: 2. (You implemented this function in the previous program.) The default constructor to initialize the state of your class. The default constructor will read the data from the file "nursery_stock.txt" into the dynamic array STR. If STR becomes full, the function should call the function "double_size" to double the size (capacity) of STR. Remember, count, size, and STR are private members of your class and do not need to be passed to a member function of your class. 3. (You implemented this function in the previous program.) is_Empty is a Boolean public member function of the class. It has no formal parameters because count is a member of the state of the class (private member) and does not need to be passed to it because the state of the class is known to all member functions of the class. If count=0 then true is returned; otherwise false is returned. 4. (You implemented this function in the previous program.) is_Full is a Boolean public member function of the class. It has no formal parameters because count and size are members of the state of the class (private members) and they do not need to be passed to it because the state of the class is known to all member functions of the class. If count-size then true is return; otherwise false. The size is the capacity which is the total number of cells allocated to STR. 5. (You implemented this function in the previous program.) search is an integer public member function that has only one formal parameter, the key key is the plant name for the record you are searching for. The array of records, STR and count are members of the state of the class and do not need to be passed to a member function of the class; The function will return the location of key in STR if it is there; otherwise -I is returned 6. (You implemented this function in the previous program.) add is a void public member function that inserts information for an order record into STR. Duplicates plant names are okay, add will prompt the user for the plant name (pname), county name (cname), plant cost (plant_cost), and the quantity (quantity). You may call process record to re- process STR when you add a new record, add has no formal parameters. Remember, to call the function double_size if STR is full before you add a new order record. 7. (You implemented this function in the previous program.) Overload the operator " as member function of order_class with chaining. This function will have the same functionality as the "remove" function from the previous assignment. Recall the following about the function remove: "remove is a public member function that deletes all records with the plant name that matches the value stored in key. If duplicate records exist with the same plant name they must all be deleted. "remove" has only one formal parameter, the key." Note, because we are overloading with chaining we must return the current object this. 8. (You implemented this function in the previous program.) double size is a void public member function that doubles the size (capacity) of STR. "double_size" has no formal parameters because size, count and STR are all members of the state of the class, order_class. First, size is multipled by two, second, memory is allocated using the statement "order_record temp = new order_record size); third the records in STR are copied into temp with the statement "templi]=STR[i]" using a for loop. Forth, the old memory for STR is de-allocated using "delete [] STR"; Finally, STR is set to point to the new memory pointed to by temp using "STR = temp". 9. (You implemented this function in the previous program.) process has no formal parameters because they are already declared in the state of the class. The function will calculate the net cost of the purchase (net_cost), the tax rate (tax_rate), the tax on the purchase (purchase_tax), the discount rate (discount_rate), the discount on the purchase (discount), and the total cost total cost). Please consider the following information to help you implement the necessary calculations: a. The tax rate (in percent) on a purchase is based on the county where the purchase was made. If the county was dade, the tax rate is 5.5%, if the count is broward, the tax rate is 5%; if the county was palm, the tax rate is 6%. b. The net cost of an order (net_cost), which does not include tax, is calculated by the following: net_cost={quantity x plant_cost) c. The discount is based on the quantity of plants in the purchase. The discount is determined as follows: If quantity equals 0, then the discount percentage is 0% of the net cost; If I60 then discount percentage is 14% Note: Apply discount percentage after the net cost has been calculate discount = net_cost * (discount_percentage)/100; (drop / 100 if you converted the discount_percentage to a decimal) d. The tax on a purchase (order_tax) is calculated by the following formula: purchase_tax = (net_cost * tax_rate / 100 (drop/100 if you converted the rate from a percentage e. The total cost of a purchase (rounded to the nearest hundredth) is calculated by the following formula: total_cost = net_cost + purchase_tax - discount. Note: All tax and cost calculations should be rounded to the nearest hundredths. 10.(You implemented this function in the previous program.) Overload operator " to your #include statements in your source file. Add "#include "to your #include statement in your source file. Add #include 'all formatting of output 4. Copy of Nursery_stock.txt: owl dade 10.55 100 hibiscusbroward 15.82 15 rose dade 9.99 45 carnation palm 7.99 32 rose palm 7.99 60 widow palm 25.75 5 carnation dade 12.55 10 carnation dade 12.55 8 lilly broward 6.92 150 xerabtgemum palm 13.63 50 yarrow dade 22.85 20 zenobia palm 37.19 32 zephyranthes broward 62.82 40 daisy broward 15.99 80 aconitum dade 30.02 72 amaryllis dade 16.14 65 bogonia broward 18.45 3 bellflowbroward 2.96 200 bergenia palm 85.92 10