0% found this document useful (0 votes)
73 views

Quiz 3 Solution

The document describes an object-oriented programming quiz to write code for a class diagram. The class diagram models customers who can place orders, with subclasses of normal orders and special orders. The solution provides the code for the customer, order, normalOrder, and specialOrder classes and their methods to match the class diagram.

Uploaded by

Zuhoor Uddin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

Quiz 3 Solution

The document describes an object-oriented programming quiz to write code for a class diagram. The class diagram models customers who can place orders, with subclasses of normal orders and special orders. The solution provides the code for the customer, order, normalOrder, and specialOrder classes and their methods to match the class diagram.

Uploaded by

Zuhoor Uddin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Riphah International University I-14 Main Campus

Faculty of Computing

Object Oriented Programming

Quiz

Write down the code for following Class Diagram?


Solution:
Header Files:
#include "string"
#include "iostream"

using namespace std;

class customer
{
private:
string name;
string location;
public:
customer();
customer(string,string);
void setName(string);
string getName();
void setLocation(string);
string getLocation();
void sendOrder();
void receiveOrder();
};

class order
{
private:
string number;
string date;
public:
order();
order(string, string);
void setNumber(string);
string getNumber();
void setDate(string);
string getDate();
void confirm();
void close();
};

class normalOrder : public order


{
private:
string number;
string date;
public:
normalOrder();
normalOrder(string,string);
void setNumber(string);
string getNumber();
void setDate(string);
string getDate();
void dispatch();
void receive();
};

class specialOrder :public order


{
private:
string number;
string date;
public:
specialOrder();
specialOrder(string, string);
void setNumber(string);
string getNumber();
void setDate(string);
string getDate();
void dispatch();
};

Source File:
using namespace std;

customer::customer()
{
this->name = "";
this->location = "";
}
customer::customer(string name, string location)
{
this->name = name;
this->location = location;
}

void customer::setName(string name)


{
this->name=name;
}
string customer::getName()
{
return name;
}

void customer::setLocation(string location)


{
this->location=location;
}
string customer::getName()
{
return location;
}

void customer::sendOrder()
{
//you have to write code for send Order
}

void customer::receiveOrder()
{
//you have to write code for receive Order
}

order::order()
{
//same like customer constructor without aurgument
}
order::order(string number, string date)
{
//same like customer constructor with aurgument
}

void order::setNumber(string number)


{
//Same setter like customer
}
string order::getNumber()
{
//Same getter like customer
}

void order::setDate(string date)


{
//Same getter like customer
}
string order::getDate()
{
//Same getter like customer
}

void order::confirm()
{
// confirm order code;
}

void order::close()
{
//close order code;
}

normalOrder::normalOrder()
{
//same like customer constructor without aurgument
}
normalOrder::normalOrder(string number, string date)
{
//same like customer constructor with aurgument
}

void normalOrder::setNumber(string number)


{
//Same setter like customer
}
string normalOrder::getNumber()
{
//Same getter like customer
}

void normalOrder::setDate(string date)


{
//Same setter like customer
}
string normalOrder::getDate()
{
//Same getter like customer
}

void normalOrder::dispatch()
{
// confirm dispatch code;
}

void normalOrder::receive()
{
//close receive code;
}

specialOrder::specialOrder()
{
//same like customer constructor without aurgument
}
specialOrder::specialOrder(string number, string date)
{
//same like customer constructor with aurgument
}

void specialOrder::setNumber(string number)


{
//Same setter like customer
}
string specialOrder::getNumber()
{
//Same getter like customer
}

void specialOrder::setDate(string date)


{
//Same setter like customer
}
string specialOrder::getDate()
{
//Same getter like customer
}
void specialOrder::dispatch()
{
// confirm dispatch code;
}

Main File:
using namespace std;

int main()
{
customer c;
normalOrder no;
specialOrder sp;

You might also like