Question

RFIDs and lot Internet of things lloT) is one of the hottest technologies at the moment. The concept of loT is to provide obj
Write a method to get the containers Add a virtual function called getContentList, or will returnering This function will be in c++ please
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Screenshot

Ship ContainerMain.cpp - X Ship Container.cpp Ship Container.h Ship ContainerMain 5 //Test main 6 #include ShipContainer.h

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.

Add a comment
Know the answer?
Add Answer to:
in c++ please RFIDs and lot Internet of things lloT) is one of the hottest technologies...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • please write the code in C++ 2 Base class File 3 Derived class PDF 3.1 Class...

    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...

  • Project Description Complete the Film Database program described below. This program allows users to store a...

    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 in c++. 4 Derived class JPG 4.1 Class declaration • The class JPG inherits...

    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()...

  • 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 me...

    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...

  • Q1. Write a recursive function in C++ void printNumberedChars(string str, int i=0) { ... } which...

    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 in c++ please Imagine you are writing a program to manage a shopping list. Each...

    Write in c++ please Imagine you are writing a program to manage a shopping list. Each shopping list item is represented by a string stored in a container. Your design requires a print function that prints out the contents of the shopping list Using a vector to hold the shopping list items, write a print function to print out the contents of a vector of strings. Test your print function with a main program that does the following: 1. Create...

  • I should show tables with info after clicking on the buttons in Android Studio. I still...

    I should show tables with info after clicking on the buttons in Android Studio. I still can not get what I should write inside OnClick function and how to use containers for printing tables. Please help me! import androidx.appcompat.app.AppCompatActivity; import android.content.Context; import android.os.Bundle; import android.text.Layout; import android.view.LayoutInflater; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; import java.util.ArrayList; public class MainActivity extends AppCompatActivity { LinearLayout container; ListView ListView1; ListView ListView2; ListView ListView3; @Override protected void onCreate(Bundle savedInstanceState)...

  • Define a C++ class managing objects using a Linked List. (10 points) Define a C++ class...

    Define a C++ class managing objects using a Linked List. (10 points) Define a C++ class named "BirthdayList" that manages a list of Birthday objects as a linked list maintaining the order of entry (first birthday should be displayed first). Write a main function to show that you can add a list of birthdays and print out that list in the order that you have entered. (5 points) Add a "search" method into the "BirthdayList" class that accepts a Birthday...

  • its about in C++ You will implement a simple calendar application The implementation should include a class named Calendar, an abstract class named Event and two concrete classes named Task an...

    its about in C++ You will implement a simple calendar application The implementation should include a class named Calendar, an abstract class named Event and two concrete classes named Task and Appointment which inherit from the Event class The Event Class This will be an abstract class. It will have four private integer members called year, month, day and hour which designate the time of the event It should also have an integer member called id which should be a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT