For this project we’ll consider a small business that needs an order tracking system. An Order is placed by a customer to purchase a product. The order system must be a menu-driven system that allows the user to add orders, view an order, find an order(s) by date, or list all orders made in that run of the program. We will not “persist” (save it to disk) the data from one program run to another, meaning we’ll have to enter all data every time.
Data analysis: An order is comprised of an order number, a date of order, a customer placing the order, and one product. A customer is comprised of a first name, a last name, and a company phone number. A product is comprised of a sku (product number) a description, and a unit price.
In this assignment, you’ll need to create unrelated classes for each object mentioned (notice they are nouns; when analyzing data needs before writing a program, the classes you’ll need to create are usually people, places, things, and transactions mentioned by the client), Product, Customer, and Order. You may want to create another class to encapsulate the entire operation and act as “program central”.
Each class should have at least two constructors, appropriate set and get methods; you’ll need to overload the stream insertion and extraction operators for each class so that the program user can be prompted for the required inputs that are added directly into the objects. Your driver program used to test your application, should present a simple menu as stated above or call your “central” class; it should also serve as the data repository (where your data is stored) and allow the functionality stated in paragraph one. The Date class is provided (you’ll need to overload the comparison operators) see the Date.h and Date_M.cpp files for details.

Please help
Or
Can you give me a sample of this ?????????????????

What have you done so far...? What specifically do you need help with?

Do you have any thoughts on how to solve the problem? If so describe them...If you have any code, post it so we can see where you are at with the problem.

EDIT: lol few seconds behind niek_e

Here is my code

#pragma once

#include<string>

using namespace std;

class Customer
{
public:
	Customer();
	Customer( string, string, string );
	Customer( Customer& );//Copy constructor
	void setFName( string );
	void setLName( string );
	void setPhone( string );
	string getFName();
	string getLName();
	string getPhone();
	string getCustomerData();
	bool operator<( Customer& );
	bool operator>( Customer& );
	bool operator==( Customer& );
	friend ostream& operator<<( ostream& stream, Customer& c );
	friend istream& operator>>( istream& stream, Customer& c );
private:
	string firstName;
	string lastName;
	string phone;
	void setData( string, string, string );
};

#pragma once
#include<iostream>
using namespace std;
class Date
{
public:
	Date();
	Date(int, int, int);
	int getMonth();
	int getDay();
	int getYear();
	void print();
	/*You'll need to add some sets
	You'll need to overload some comparision operators
	such that dates can be compared < > == etc.
	You'll also need to overload << and >> for convenience
	of use.
	*/
private:
	int month;
	int day;
	int year;
	int checkDay(int);//utility method
}; //end Date

#pragma once
#include "Customer_h.h"
#include "Product_h.h"
//include Date

class Order
{
public:
	Order();
	Order( int, int, int, int );//date and prod num only
	Order(int, Customer, Product);
	Order( Order& );
	void setCustomer(Customer& );
	void setOrderNum( int );
	void setProduct( Product& );
	int getOrderNum();
	Customer getCustomer();
	Product getProduct();
	friend ostream& operator<<(ostream&, Order&);
	friend istream& operator>>(istream&, Order& );

private:
	int ordNum;
	Customer customer;
	Product product;
	//Date goes here too
};

#pragma once

#include<string>
using namespace std;

class Product
{
public:
	Product();
	Product( int, string, double );
	Product( Product& p );
	void setSKU( int );
	void setDesc( string );
	void setPrice( double );
	int getSKU();
	string getDesc();
	double getPrice();
	bool operator< ( Product& );
	bool operator==( Product& );
	friend ostream& operator<<( ostream&, Product& );
	friend istream& operator>>( istream&, Product& );

private:
	int sku;
	string description;
	double price;
};

#include "Customer_h.h"

Customer::Customer()
{
	setData( "FN", "LN", "PH");
}

Customer::Customer(string fn, string ln, string ph)
{
	setData( fn, ln, ph );
}
Customer::Customer(Customer &other)
{
	setData( other.firstName, other.lastName, other.phone);
}
void Customer::setData( string fn, string ln, string ph )
{
	setFName( fn );
	setLName( ln );
	setPhone( ph );
}
void Customer::setFName( string fn )
{
	firstName = fn;
}
void Customer::setLName(string ln)
{
	lastName = ln;
}
void Customer::setPhone( string ph )
{
	phone = ph;
}
string Customer::getCustomerData()
{
	string temp = getLName() + ", " + getFName() + " " + getPhone() + "\n";
	return temp;
}
string Customer::getFName()
{
	return firstName;
}
string Customer::getLName()
{
	return lastName;
}
string Customer::getPhone()
{
	return phone;
}
bool Customer::operator<( Customer& c)
{
	if( lastName == c.lastName)
		return firstName < c.firstName;
	else
		return lastName < c.lastName;
}
bool Customer::operator>( Customer& c)
{
	if( lastName == c.lastName)
		return firstName > c.firstName;
	else
		return lastName > c.lastName;
}
bool Customer::operator==( Customer& c)
{
	if( lastName == c.lastName)
		return firstName == c.firstName;
	else
		return lastName == c.lastName;
}
ostream& operator<<( ostream& stream, Customer& c )
{
	stream << c.getCustomerData();
	return stream;
}
istream& operator>>(istream& stream, Customer& c )
{
	stream >> c.firstName >> c.lastName >> c.phone;
	return stream;
}


#include<iostream>
#include "Date_h.h"

using namespace std;
Date::Date()
{
	month = 4;
	day = 1;
	year = 2008;
}
Date::Date(int m, int d, int y)
{
	if( m > 0 && m <= 12)
		month = m;
	else
	{
		m = 1;
		cout << "Month invalid, set month to 1.\n";
	}
}
int Date::getMonth()
{
	return month;
}
int Date::getDay()
{
	return day;
}
int Date::getYear()
{
	return year;
}
void Date::print()
{
	cout << month << '/' << day << '/' << year;
}
int Date::checkDay(int testDay)
{
	//why is first value zero?
   int daysPerMonth[  ] = { 0, 31, 28, 31, 30, 31, 30,
                              31, 31, 30, 31, 30, 31 };

	// make sure testDay is within valid range
   if ( testDay > 0 && testDay <= daysPerMonth[ month ] )
      return testDay;

   if ( month == 2 &&     // if month is Februaryand day is 29,
       testDay == 29 && //  Check for leap year
       ( year % 400 == 0 || (year % 4 == 0 && year % 100 != 0 ) ) )
      return testDay;

   cout << "Day " << testDay << " invalid. Set to day 1.\n";

   return 1;  // leave object in consistent state if invalid value was provided

}


#include<iostream>
#include<iomanip>
#include "Customer_h.h"
#include "Product_h.h"
#include "Order_h.h"

Order::Order()
{
	setOrderNum(0);
}
Order::Order(int num, Customer c, Product p)
{
	setOrderNum( num );
	setCustomer(c);
	setProduct(p);
}
Order::Order( int num, int m, int d, int y )
{

}
Order::Order(Order & other)
{
	setOrderNum(other.ordNum);
	setCustomer(other.customer);
	setProduct(other.product);
}
void Order::setOrderNum( int num )
{
	ordNum = num;
}
void Order::setCustomer(Customer & c)
{
	customer = c;
}
void Order::setProduct(Product & p)
{
	product = p;
}
int Order::getOrderNum()
{
	return ordNum;
}
Product Order::getProduct()
{
	return product;
}
Customer Order::getCustomer()
{
	return customer;
}
ostream& operator<<( ostream& stream, Order& o )
{
	stream << "Order Number:\t" << o.ordNum
		<< "\n\nCustomer: \t" << o.customer
		<< "\n\nProduct:\t" << o.product
		<<endl;
	return stream;
}
istream& operator>>(istream& stream, Order& o )
{
	stream >> o.ordNum >> o.customer >> o.product;
	return stream;
}


#include "Product_h.h"

Product::Product()
{
	setSKU(0);
	setDesc("Not set");
	setPrice(0.0);
}

Product::Product(int  num, string desc, double cost)
{
	setSKU(num);
	setDesc(desc);
	setPrice(cost);
}
Product::Product(Product &p)
{
	setSKU(p.sku);
	setDesc(p.description);
	setPrice(p.price);	
}
void Product::setDesc(string desc)
{
	description = desc;
}
void Product::setSKU(int num)
{
	sku = num > 0 ? num : 0;
}
void Product::setPrice(double cost)
{
	price = cost > 0 ? cost : 0.0;
}
int Product::getSKU()
{
	return sku;
}
string Product::getDesc()
{
	return description;
}
double Product::getPrice()
{
	return price;
}
bool Product::operator <(Product & p)
{
	return sku < p.sku;
}
bool Product::operator ==(Product & p)
{
	return sku == p.sku;
}
ostream& operator<<(ostream& stream, Product& p )
{
	stream.setf( ios::fixed | ios::showpoint);
	stream.precision(2);
	stream << p.sku << ' ' << p.description << ' ' << p.price << '\n';
	return stream;
}
istream& operator>>(istream& stream, Product& p )
{
	stream >> p.sku >> p.description >> p.price;
	return stream;
}


#include <iostream>
#include <Order_h.h>
#include <Date_h.h>
#include <Customer_h.h>
#include <Product_h.h>

using namespace std;

const char quit ='4';
int numorder,ordernumber;


enum menu{Place = 1,View,Find,Exit};

int nm,dd,yy,num;
//function prototypes
void background();
void InputCustomer(string fn, string ln, string ph, int mm, int dd, int yy,int  num, string desc, double cost);
char UserMenu();

int main ()
{	
	background();
	char userChoice = ' ';

    while(userChoice != Exit)
    {
        userChoice = UserMenu();

        switch(userChoice)
        {
            case '1': 
                      break;
            case '2': 
                      break;  
            case Exit: cout << endl << "Quitting ... " 
                                 << endl << endl;
            return 0;
        }
    }
    return userChoice;
}

char UserMenu()
{
    char userChoice = ' ';
    while(userChoice == ' ')
    {
		cout << "\nPlease make a selection: ";
        cin >> userChoice;
        switch (userChoice)
        {
               case '1':    
                    for (int i=1 ; i < numorder;i++)
					{
						InputCustomer(fn,ln,ph,ordernumber,mm,dd,yy,num,desc,cost);
						return userchoice;
					}
					sytem("cls");
					print();
					break;
               case '2':
				    
				    for (int i=1 ; i < numorder;i++)
					{
					//Print Date
						 Date d(mm,dd,yy);
						 d.print();
						 cout << endl;
					// Print All Others
						Order ordernumber(ordernumber);
						ordernumber.print();
						Customer cus(fn,ln,ph);
						cus.print();
						Product pro(num,desc,cost);
						pro.print();
							
						cout << ord << endl;
						cin  >> ord;
						cout << ord << endl;

					}
					return 0;
					break;
			 //  case '3':	    
			//		break;
               case quit: 
					return userChoice;
               break;
               default:
                       cout << "\nInvalid Menu Item.Please try again.!\n";
					   userChoice = ' ';
               break;
       }
    }
	return userChoice;
}//end main

//Funtion Definitions
void InputCustomer(string fn, string ln, string ph,int ordernumber,int mm, int dd, int yy,int  num, string desc, double cost)
{
	cout<<" Enter order numnber : ";
	cint<<ordernumber;

	cout<<"\n Enter mm, "," dd"," yy";
	cin >> mm>>dd>>yy;

	cout<<"\nEnter customer first name"," last name "," and Phone number: ";
	cin>>fn>>ln>>ph;

	cout<<"\n Enter product number"," price"," and decription: ";
	cin>> num>cost>>desc;
}

void background()
{
	cout<<" How many order do you want : ";
	cin >>numorder;
	system("cls");
	cout<<"\n***********************************************************\n";
	cout<<"*                                                         *\n";
	cout<<"*         Welcome to the Order Tracking Sytem	    	  *\n";
	cout<<"*                                                         *\n";    
	cout<<"*---------------------------------------------------------*\n"
		 <<"*            " <<Place
		 <<")Place the order                            *\n"
		 <<"*            " <<View	 
		 <<")View the order                             *\n"
		 <<"*            "<<Find
		 <<")Find the order by date                     *\n"
		 <<"*            " <<Exit
		 <<")Exit                                       *\n"
		 <<"***********************************************************\n"
		 << endl;
}

I would like to ask what/where did I did wrong? What do I have to do next to fix it?

Also How can I find the order by date?

Please help. Thanks

Does it compile?
if yes: what output were you expecting, and what is your output?

Use code-tags when posting code here, it makes it easier to read (smilies will disappeare) and your chance that you'll get some help will increase

Ok .I got succeed when I fix all the tiny mistakes but The output was not what I expected. I want it to appear all the data ( date, order......) that I input when I click "2" but It just did nothing . PLease help. Just tried to help me which code is totally worng and don't care about any tiny mistakes . Thanks

Use code tags, repost your code, and maybe you touch it up first, making that code more readable.

case '1':
for (int i=1 ; i < numorder;i++)
{
InputCustomer(fn,ln,ph,ordernumber,mm,dd,yy,num,desc,cost);
return userchoice;
}
sytem("cls");
print();
break;

btw, return placed correctly? what the hell is system(;) )?

Also How can I find the order by date?

I'll be honest, I haven't looked at your code at all, partly because its so long and the formatting makes it difficult to read...

But anyway, my first thought when reading the question was to make a struct containing all the required information, i.e. struct order which contains the date of the order, the sku, the description, the price, and a pointer to the next order (like a list). This way, you can add orders in constant time....Then you can just create accessors to return the information that you query...

Another way you could do it is in each class, create side-by-side arrays (or vectors to have the added capability of resizing the array to add a new order). That is, you have a date array, a sku array, etc, all of the same size, and you store corresponding orders into the corresponding elements of each array...That way, you just search for the date in the array, and use the index number of the date to return the order (stored in the same index of the other array)...

In any case, of these two ideas I like the list-structure one better, because it can add new nodes in constant time, and will take O(n) time -- roughly proportional to the length of the list (number of orders) -- to find any specific order, which will actually be the same case as with the arrays (because although you have constant time access, you don't know where to access!)

Of course, someone might be able to come up with a better idea...

Dear. I would like to ask how to do I make a pointer to the next order (save or make a list in order view the all data and find the data).

Also. I would like to ask what wrong with this code. It doesn't work.

pday =1;
pyear;
int daysPerMonth[  ] = { 0, 31, 28, 31, 30, 31, 30,
                              31, 31, 30, 31, 30, 31 };
int testMonth1 [ ] = {1,3,5,7,8,10,12};
int testMonth2 [ ] = {2,4,6,9,11};

if( mn.month >0 && mn.month < 13 &&
		        dd.day > 0 && dd.day <= 31 && yy.year > 2006 && yy.year < 3000)
	 {
		 if (mn.month ==2 && dd.day == 29 && 
                         ( yy.year % 400 == 0 || (yy.year % 4 == 0 && yy.year % 100 != 0 ) ) )
		 {
			if (mn.month == testMonth1[mn.month] && mn.month <32)
			{
				if (mn.month = testMonth2[mn.month] && mn.month <31)
				{
					pmonth = mn.month;
					pday = dd.day;
					pyear = yy.year;
				}
			}
		 }
	else
		{
			cout<<" Invalid date. Please try again";
			cout<<"\nEnter the date by mm, dd yy: ";
			cin >> mn.month>>dd.day>>yy.year;
		}

Ofcourse it doesn't, just look at the first 3 lines.
- Where is the rest of the code?
- What is it suppose to do?
- Does it compile?
- What output are you expecting?
- What output do you get?

And please please with sugar on top USE CODE TAGS...
(this time click the link and read it)

code = cplusplus

No spaces in code = cplusplus, like this:

[code=cplusplus] // paste code here

[/code]

pday =1;
pyear;

Are the data types defined earlier? C++ requires you to declare the data type.

Hey guys. I have done the project so far but I would like to like to ask how could I save my data every time I input in order to view . I tried to use the dynamic array and the istream but It seems not to work with me. PLeasee help assssssssssssssspppppppppppppppppppppppppppppppppppppp

Hey guys. I have done the project so far but I would like to like to ask how could I save my data every time I input in order to view . I tried to use the dynamic array and the istream but It seems not to work with me. PLeasee help assssssssssssssspppppppppppppppppppppppppppppppppppppp

No one can tell you what the problem is because you haven't posted what you have tried.

I tried to use the dynamic array and the istream but It seems not to work with me.

There is no way to know what you did here so how can we help?

This article has been dead for over six months. Start a new discussion instead.