Word description of classes design task?

I have this question:

Start with publication, book and tape classes. Add a base class sales that holds an array of three floats so that it can record the dollar sales of a particular publication for the last three months. Include a getdata() function to get three sales amounts from the user and a putdata() function to display the sales figures. Alter the book and tape classes so they are derived from both publication and sales. An object of class book or tape should input sales data along with its other data. Write a main() program to create a book object and a tape object and exercise their input/output capabilities.

I didn't understand it very well, in which class should I include getdata() & putdata() functions! I wrote this code till now:

   #include<iostream>
#include<string>
using namespace std;
class sales{
private:
    float dollar[3];
public:
    void getData(float f1,float f2, float f3){
        dollar[0]=f1;// sales of first month
        dollar[1]=f2;// sales of second month
        dollar[2]=f3;// sales of third month
    }
    void putData(){
        int count=0;
        while(count!=3){
        cout<<dollar[count]<<"\t$"<<endl;
        count++;
        }
    }
};


class publication:public sales{
private:
    string PubName;
    int PubYear;
public:
    void SetName(string s){
        PubName=s;
    }
    string GetName(){
        return PubName;
    }
        void SetYear(int y){
        PubYear=y;
    }
    int GetYear(){
        return PubYear;
    }
};

class book:public publication{
private:
    string Author;
public:
    void SetAuthor(string a){
        Author=a;
    }
    string GetAuthor(){
        return Author;
    }


};

class tape:public publication{
private:
    string singer;
public:
    void SetSinger(string s){
        singer=s;
    }
    string GetSinger(){
        return singer;
    }


};



int main() {
    tape Tobj;
    book Bobj;

// input/output capabilities of tape object.
    Tobj.getData(33,55,88);
    Tobj.SetName("General music tape");
    Tobj.SetSinger("David");
    Tobj.SetYear(2011);
    cout<<Tobj.GetName()<<" for "<<Tobj.GetSinger()<<"\nattained the following sales for the last three months:"<<endl;
    Tobj.putData();
    cout<<"in "<<Tobj.GetYear()<<endl<<endl<<endl;

// input/output capabilities of book object.    
    Bobj.getData(65.6,585,808.2);
    Bobj.SetName("Art of math");
    Bobj.SetAuthor("John");
    Bobj.SetYear(2009);
    cout<<Bobj.GetName()<<" for "<<Bobj.GetAuthor()<<"\nattained the following sales for the last three months:"<<endl;
    Bobj.putData();
    cout<<"in "<<Bobj.GetYear()<<endl<<endl<<endl;
    system("pause");

return 0;
}

Is what I did true!

Answers


"Include a getdata() function to get three sales amounts from the user and a putdata() function to display the sales figures."

With the way that it is worded, it suggests to me that getData() and putData() should be part of a "User" class. But since there isn't a "User" class, it looks to me like you put it in the right place.


Need Your Help

What other programming languages have a Smalltalk-like message-passing syntax?

objective-c syntax language-design smalltalk message-passing

What languages are there with a message-passing syntax similar to Smalltalk's? Objective-C is the only one I'm familiar with. Specifically, I was wondering if any other language implementations exist

Creating a Binary Expression Tree given prefix notation in java

java recursion binary-tree

How should we construct the binary tree of the following "prefix" order expression?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.