help please ! senior !

Shipping Container
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <string>

#ifndef SHIPPINGCONTAINER_H
#define SHIPPINGCONTAINER_H

using namespace std;

class ShippingContainer{
private:
	int containerID;
public:

	//ShippingContainer (int containerID);
    ShippingContainer(){
		containerID = 0;
	}// constructors

	void setContainerID( int );//mutator
	int getContainerID();//accessor
	string IntToString(int i);// convert the ID integers to a string
    
	virtual void setManifest( string ) = 0;
	virtual string getManifest();//virtual function to output the empty string as the content of the shipping container.
};

void ShippingContainer :: setContainerID( int thecontainerID ){
	containerID = thecontainerID;
}
int ShippingContainer :: getContainerID(){
	return containerID;
}

string ShippingContainer :: getManifest(){
	//virtual function to output the empty string as the content of the shipping container.
	//cout<< "";
    return("");// return an empty string.
}

#endif   
RFID container
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "ShippingContainer.h"
#include "ManualShippingContainer.h"

class RFIDShippingContainer : public ShippingContainer{
	// derived class for RFID method of inventorying the container
private:
	string content;// for the content of the item
        
	int quantity;// for the quantity of the added items.
      
public:

	//RFIDShippingContainer (string content, int quantity); // string content represents, for example, "4 crates of apples  
    RFIDShippingContainer ();// constructors
        
    string getContent();// input string of the content.
    int add();// add the item, say add one crate of pears
   
    virtual void setManifest( string ); // set the manifest 
    virtual string getManifest(); // return the string of manifest

};

//RFIDShippingContainer ::RFIDShippingContainer (string content, int quantity){}

RFIDShippingContainer ::RFIDShippingContainer(){
	content ="";
	quantity = 0;
}

void RFIDShippingContainer :: setManifest( string theManifest ){
	content = theManifest;
}

string RFIDShippingContainer :: getContent(){
    return content;
}

string RFIDShippingContainer :: getManifest(){
	cout<< content<<endl;
	return content;
}

int RFIDShippingContainer :: add(){
	quantity ++;
	return quantity;
}
Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "ShippingContainer.h"
#include "ManualShippingContainer.h"
#include "RFIDShippingContainer.h"

int main(){
	RFIDShippingContainer theRFIDShippingContainer;
	ShippingContainer *theShippingContainer[6] ;
	theShippingContainer[0] =	new ManualShippingContainer;
	theShippingContainer[1] =	new ManualShippingContainer;
	theShippingContainer[2] =	new ManualShippingContainer;
	theShippingContainer[3] =	new RFIDShippingContainer;
	theShippingContainer[4] =	new RFIDShippingContainer;
	theShippingContainer[5] =	new RFIDShippingContainer;

	theShippingContainer[0]->setContainerID(5);
	theShippingContainer[0]->setManifest("Manual Shipping Manifest");

	theShippingContainer[1]->setContainerID(10);
	theShippingContainer[1]->setManifest("Manual Shipping Manifest");

	theShippingContainer[2]->setContainerID(15);
	theShippingContainer[2]->setManifest("Manual Shipping Manifest");

	theShippingContainer[3]->setContainerID(20);
	theShippingContainer[3]->setManifest("crate of apple");
	theShippingContainer[3]->setManifest("crate of apple");
	theShippingContainer[3]->setManifest("crate of apple");
	theShippingContainer[3]->setManifest("crate of apple");
	theShippingContainer[3]->setManifest("crate of oranges");
	theShippingContainer[3]->setManifest("crate of oranges");
	theShippingContainer[3]->setManifest("crate of oranges");
	theShippingContainer[3]->setManifest("crate of bananas");

	theShippingContainer[4]->setContainerID(25);
	theShippingContainer[4]->setManifest("crate of apples");

	theShippingContainer[5]->setContainerID(30);
	theShippingContainer[5]->setManifest("crate of oranges");
	theShippingContainer[5]->setManifest("crate of oranges");
	theShippingContainer[5]->setManifest("crate of apples");

	for(int i = 0; i < 5; i++){
		int temp = theShippingContainer[i]->getContainerID();
		cout << "Container " << temp << " manifest: " << theShippingContainer[i]->getManifest()
		<< ", #" << temp << endl;
	}

	system( "pause" );//System Pause
	return 0;
}
this is my question..


To model this application, write a base class called ShippingContainer that has a container ID number as an integer. Include member functions to set and access the ID number. Add a virtual function called getManifest that returns an empty string. The purpose of this function is to return the contents of the shipping container.

Create a derived class called ManualShippingContainer that represents the manual method of inventorying the container. In this method, a human simply attaches a textual description of all contents of the container. For example, the description might be “4 crates of apples, 10 crates of pears.” Add a new class variable of type string to store the manifest. Add a function called setManifest that sets this string. Override the getManifest function so that it returns this string.

Create a second derived class called RFIDShippingContainer that represents the RFID method of inventorying the container. To simulate what the RFID chips would compute, create an add function to simulate adding an item to the container. The class should store a list of all added items (as a string) and their quantity using the data structures of your choice. For example, if the add function are invoked three times as follows:

rfidContainer.add(“crate of pears”); //add one crate of pears
rfidContainer.add(“crate of apples”); //add one crate of apples
rfidContainer.add(“crate of pears”); //add one crate of pears

At this point, the data structure should be storing a list of two items: crate of apples and crate of pears. The quantity of apples is one and the quantity of pears is two. Override the getManifest function so that it returns a string of all items that is built by traversing the list of items. In the above example, the return string would be “2 crate of pears, 1 crate of apples.”

Include other necessary functions, constructors, and destructor to all the classes above.

Finally, write a main program that creates an array of pointers to 6 ShippingContainer objects. The array should be used to store both the ManualShippingContainer objects and RFIDShippingContainer objects. Construct the main program to allow the user to decide the number of each type of objects to be stored in the array. Instantiate all the objects accordingly and demonstrate how each objects behaves differently when the same instructions are given to them. For the ManualShippingContainer objects, you will have to invoke setManifest function to set the contents. For the RFIDShippingContainer objects, you will have to invoke add to set the contents (although, if this were real, the contents of the container would “add” themselves via the RFID chips instead of requiring a human to type them in).
now the problem is i know inside RFIDContainer should have the string parameter , but i don't know how to do some function that will return automatically for my quantity if it detected my

content == content

then quantity will be keep adding .

someone help please...
Well, obviously you need some sort of container in RFIDShippingContainer. A map with a string as the key and the count as the associated data may work.

One string and one count simply aren't going to do it.
if i use data structure to do? as the question required, then it is easier?
As already suggested to you both by myself (in your other thread) and and now by cire - you could do with some sort of data container ( vector or list or linked list, etc.. ) in the RFID container class - if you don't know of any of these data structures I have mentioned, then you are on a losing streak!

Are you familiar with arrays??

If this is part of a C++ course and you are expected to hand in this work to be graded - then why have you been given an assignment which needs
some C++ information that you have not been taught - this surprises me.

help us to help you (as they say)...

Edited for empathy..

Last edited on
Topic archived. No new replies allowed.