Instructions:

Please read the following instructions carefully before submitting assignment:

It should be clear that your assignment will not get any credit if:

 

§  The assignment is submitted after due date.

§  The assignment is submitted via email.

§  The assignment is copied from Internet or from any other student.

§  The submitted assignment does not open or file is corrupt.

§  It is in some format other than .cpp.

 

1)      Note: You are supposed to submit your assignment in .cpp format. Any other formats like scan images, PDF, zip, doc, rar and bmp etc will not be accepted. All types of plagiarism are strictly prohibited.

 

For any query about the assignment, contact at CS304@vu.edu.pk

Student Learning Outcomes

Students will be able to:

o   Define base and derived classes with their respective data members and member functions

o   Implement Multiple Inheritance.

 

For any query about the assignment, contact at cs304@vu.edu.pk

GOOD LUCK!

 

Marks: 20 

 

Problem Statement

Consider yourself working as a software engineer in a marketing company of both hardware and software. The IT manager has given you a task to model a part of their simple advertising system. In this system, there will be four classes named Item, Sales, hwItem (Hardware Item), swItem (Software Item)

Steps to follow:

1.      Create a base class Item that should store the title of the item (a string) and its price (a float).

2.      Then create another base class called Sales which should contain an array of three floats so that it can record the sale in rupees of a particular item for the last three months.

3.      After that derive two classes hwItem (hardware item) and swItem (software item) from both Item and Sales classes. The hwItem class should hold category of the item and its original manufacturer (om), whereas the swItem class should contain the type of the software and the Operating System (os) under which it works.

4.      Each class should have its own getData() and displayData() functions to input and output data respectively.

The following hierarch of classes should be used for the assignment solution.

 

 

Sample Output:

                                                                                  Good Luck!

 

 

 

Views: 790

Attachments:

Replies to This Discussion

Watch this Video

CS304 Assignment 3 Solution Spring 2018

Assignment File in .Cpp Format:

                        CS304 Assignment 3.Cpp

Solution file attach

MC170202725.cpp

Correct Codding

/CS304-Object Oriented Programming
//Assignment #3

#include<iostream>
using namespace std;

class Item
{
protected:

string Title;
float price;
public :
void getItem()

{
cout"Please enter product title : ";
cin>>Title;
cout"Please enter Price : ";
cin>> price;
}
void displayItem()
{
cout"\nTitle and Price : " Title "\t" price;
}
};
class Sales
{
protected :
float sale_per_item[3];
public :
void getSales()
{
cout"\nEnter sales figure for 3 months <Press enter after each entry > : ";
for(int i=0; i<3; i++)
{
cin>>sale_per_item[i];
}
}
void displaySales()
{
cout"\nThese are sales figures for last 3 months: \t";
for(int i=0; i<3; i++)
{
cout sale_per_item[i]"\t";
}
cout"\n\n***************\n\n";
}

};
class hardItem : Item , Sales
{
private :
string category;
string O_Manufacturer;
public :
void gethardItem()
{
getItem();
cout "Enter Category : ";
cin>> category;
cout"Please enter Manufacturer : ";
cin >>O_Manufacturer;
getSales();
}
void displayhardItem()
{
displayItem();
cout"\nCategory and Manfucaturer is:"category "\t" O_Manufacturer ;
displaySales();
}
};
class softItem :Item , Sales
{
private :
string category ;
string OS;
public :
void getsoftItem()
{
getItem();
cout"Enter category : ";
cin >> category;
cout"Enter Operating System : ";
cin >>OS;
getSales();

}
void displaysoftItem()
{
displayItem();
cout"\nEnter category and OS : " category "\t" OS ;
displaySales();
}
};
main()
{
softItem soft1;
hardItem hwd1;
hwd1.gethardItem();
hwd1.displayhardItem();
soft1.getsoftItem();
soft1.displaysoftItem();
}

RSS

SPONSORED LINKS

© 2018   Created by Muhammad Anwar Tahseen.   Powered by

Badges  |  Report an Issue  |  Terms of Service