Screenshot
Program
ShipContainer.h
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
using namespace std;
//Create base class
class ShipContainer {
//Member variable
private:
int ID;
//Member functions
public:
void setID(int id);
int getID();
virtual string getContenetList();
};
//Derived class
class ManualContenetList :public ShipContainer {
//Member variable
private:
string contentList;
//Member functions
public:
void setContentList(string content);
string getContenetList();
};
//Create next derived class
class ShippingContainerRFID:public ShipContainer{
//Member variables
private:
vector<string> contentList;
vector<int>quantity;
//Member functions
public:
void add(string content, int quant);
string getContenetList();
};
ShipContainer.cpp
//Implementation of classes
#include "ShipContainer.h"
void ShipContainer::setID(int id) {
ID = id;
}
int ShipContainer::getID() {
return ID;
}
string ShipContainer::getContenetList() {
return "";
}
void ManualContenetList::setContentList(string content) {
if (contentList == "") {
contentList += content;
}
else {
contentList += ", "+content;
}
}
string ManualContenetList::getContenetList() {
return "Container "+to_string(getID()) + " contains "
+ contentList;
}
void ShippingContainerRFID::add(string content, int quant) {
if (!(std::find(contentList.begin(),
contentList.end(), content) != contentList.end())) {
contentList.push_back(content);
quantity.push_back(quant);
}
}
string ShippingContainerRFID::getContenetList() {
string str = "Container " + to_string(getID());
for (int i = 0; i < contentList.size()-1; i++)
{
str = " contains " +
to_string(quantity[i] )+ " of "+contentList[i]+", ";
}
str = " contains " +
to_string(quantity[contentList.size() - 1]) + " of " +
contentList[contentList.size() - 1];
return str;
}
Main.cpp
//Test main
#include "ShipContainer.h"
int main()
{
//ShipContainer pointer object array
ShipContainer* shipContainer[7];
//shipContainer = new ShipContainer[7];
//3 Manual objects
ManualContenetList mContainer[3];
//3 RFID object array
ShippingContainerRFID rfid[3];
//Add 3 contents in mContainer
mContainer[0].setContentList("100 boxes of lysol
wipes");
mContainer[1].setContentList("50 boxes of 70% alcohol
hand sanitizer");
mContainer[2].setContentList("100 boxes of toilet
papers");
shipContainer[0] =&mContainer[0];
shipContainer[0]->setID(1);
shipContainer[1] = &mContainer[1];
shipContainer[1]->setID(2);
shipContainer[2] = &mContainer[2];
shipContainer[2]->setID(3);
//Display details
for (int i = 0; i < 3; i++) {
cout <<
shipContainer[i]->getContenetList() << endl;
}
return 0;
}
Output
Container 1 contains 100 boxes of lysol wipes
Container 2 contains 50 boxes of 70% alcohol hand sanitizer
Container 3 contains 100 boxes of toilet papers
Note
Please add clear picture of the question.I assume you are expecting this way.From RFID class onwards picture is not clear.
in c++ please RFIDs and lot Internet of things lloT) is one of the hottest technologies...
Project Description Complete the Film Database program described below. This program allows users to store a list of their favorite films. To build this program, you will need to create two classes which are used in the program’s main function. The “Film” class will store information about a single movie or TV series. The “FilmCollection” class will store a set of films, and includes functions which allow the user to add films to the list and view its contents. IMPORTANT:...
please write the code in C++ 2 Base class File 3 Derived class PDF 3.1 Class declaration • The class PDF inherits from File and is a non-abstract class 1. Hence objects of the class PDF can be instantiated. 2. To do so, we must override the pure virtual function clone) in the base class • The class declaration is given below. • The complete class declaration is given below, copy and paste it into your file. . It is...
Create an application that tracks electric motors in a manufacturing plant (Python and C++). The application should have a Motor class with the following properties: MotorId: Five digit string, such as "02340" Description: String RPM: Double, values in the range 10 to 10000 Voltage: Double, values in the range 1 to 500 Status: String, three characters The Status values are: ON: Motor is online and running OFF: Motor is online but not running MNT: Motor is undergoing maintenance and cleaning...
please write in c++. 4 Derived class JPG 4.1 Class declaration • The class JPG inherits from File and is a non-abstract class. 1. Hence objects of the class JPG can be instantiated. 2. To do so, we must override the pure virtual function clone() in the base class. • The class declaration is given below. class JPG : public File { public: JPG(const std::string& n, int n, int w, const double rgb()) : File(...) { // ... } *JPG()...
Q1. Write a recursive function in C++ void printNumberedChars(string str, int i=0) { ... } which prints each character of the given string str on a new line, with each line numbered 1, 2, 3, …. For example calling the function with printNumberedChars("hello"); should output the following: 1. h 2. e 3. l 4. l 5. o Q2. Write a recursive function in C++ int sumArray(const int* arr, unsigned int size) { ... } which takes an array of integers,...
Write a program that meets the following requirements: Sandwich Class Create a class called Sandwich which has the following instance variables. No other instance variables should be used: - ingredients (an array of up to 10 ingredients, such as ham, capicola, American cheese, lettuce, tomato) -condiments (an array of up to 5 condiments, such as mayonnaise, oil, vinegar and mustard) Create a two argument constructor Write the getters and setters for the instance variables Override the toString method using the...
In C++ Write a program that contains a class called VideoGame. The class should contain the member variables: Name price rating Specifications: Dynamically allocate all member variables. Write get/set methods for all member variables. Write a constructor that takes three parameters and initializes the member variables. Write a destructor. Add code to the destructor. In addition to any other code you may put in the destructor you should also add a cout statement that will print the message “Destructor Called”....
1) Given the following “BasicAccount” class #include <iostream> #include <string> class BasicAccount { private: std::string m_username ; std::string m_password ; public: BasicAccount(std::string username, std::string password) { m_username = username ; m_password = password ; } virtual std::string toString() { return "USERNAME(" + m_username + ") PASSWORD(" + m_password + ")" ; } std::string getUserName() { return m_username ; } virtual...
Please try to write the code with Project 1,2 and 3 in mind. And use java language, thank you very much. Create an Edit Menu in your GUI Add a second menu to the GUI called Edit which will have one menu item called Search. Clicking on search should prompt the user using a JOptionPane input dialog to enter a car make. The GUI should then display only cars of that make. You will need to write a second menu...