C++ Code :-
Stove.h
#include<iostream>
#include<string>
#include <thread>
#include <chrono>
using namespace std;
class Stove
{
string state;
int p;
bool elements[4];
public:
Stove() //default
{
state = "normal";
p=4;
}
//parameter constructor
Stove(string s, bool e[],int size)
{
state=s;
for(int i=0;i<size;++i)
elements[i]=e[i];
p=size;
}
//destructor
~Stove()
{
cout<<"Stove shutting down\n";
}
string GetState()
{
return state;
}
//set state
void SetState(string s)
{
state=s;
}
int GetP()
{
return p;
}
void SetElement(int n,bool q)
{
if(n>=p || n<0)
return;
elements[n]=q;
}
void clean()
{
for(int i=0;i<p;++i)
elements[i]=false;
this_thread::sleep_for(chrono::seconds(5));
if(state.compare("clean")!=0)
cout<<"Error occurred\n";
}
void boil(int n)
{
if(state.compare("normal")!=0 ||
elements[n]==false)
cout<<"Error stove
is not working\n";
elements[n]=true;
this_thread::sleep_for(chrono::seconds(3));
}
};
Main.cpp
#include<iostream>
#include "stove.h"
using namespace std;
int main()
{
bool el[4]={false,true,false,false};
Stove kenmore("normal",el,4);
cout<<kenmore.GetState()<<endl;
cout<<kenmore.GetP()<<endl;
kenmore.SetElement(3,true);
cout<<kenmore.GetP()<<endl;
kenmore.boil(0);
kenmore.boil(1);
kenmore.boil(2);
cout<<kenmore.GetP()<<endl;
kenmore.SetElement(1,false);
kenmore.clean();
kenmore.SetState("clean");
kenmore.clean();
cout<<kenmore.GetState()<<endl;
cout<<kenmore.GetP()<<endl;
return 0;
}
Screenshot of output :-

in c++ thankyou. 1. Using C++, write a program to simulate a cooking) stove. This stove...
Write a program to create a game map. A game map is a 2D array of regions, or tiles, of a world, as in the example of the figure to the right . For example, a tile with a value of 0 might represent water, 1 might represent land, 2 might represent a mountain and so forth. This map is represented as a class named CMap that has the properties: • A 2D array, having a height and width of...
C++ problem with dynamic arrays is that once the array is created using the new operator the size cannot be changed. For example, you might want to add or delete entries from the array similar to the behavior of a vector. This project asks you to create a class called DynamicStringArray that includes member functions that allow it to emulate the behavior of a vector of strings. The class should have: A private member variable called dynamicArray that references a...
Using the below files, Write a program that reads a document containing endnotes indicated in this manner, collects them in a queue, and prints them on the screen. For this lab, you will create a text file called sample.txt and put the following paragraph in it. This part is the beginning. {This part is the footnote.} This part is the end. /* Queue.h contains the declaration of class Queue. Basic operations: Constructor: Constructs an empty queue empty: Checks if a...
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”....
Use C++! This program uses the class myStack to determine the highest GPA from a list of students with their GPA.The program also outputs the names of the students who received the highest GPA. Redo this program so that it uses the STL list and STL queue! Thank you! HighestGPAData.txt* 3.4 Randy 3.2 Kathy 2.5 Colt 3.4 Tom 3.8 Ron 3.8 Mickey 3.6 Peter 3.5 Donald 3.8 Cindy 3.7 Dome 3.9 Andy 3.8 Fox 3.9 Minnie 2.7 Gilda 3.9 Vinay...
1. Implement a tostring() member function. This function will return a string representation of the LargeInteger. You should probably used string streams to implement this function. Note that the digits of the large integer are stored in reverse of their display order, e.g. the 1's place (100 ) is in index 0 of digits, the 10's place (101 ) is in index 1, etc. 2. Implement a second constructor for the LargeInteger. This constructor will be used to construct a...
Purpose This assignment is an exercise in implementing the Stack ADT using a dynamically-allocated array, as well as techniques for managing dynamically-allocated storage in C++. Assignment In this assignment, you will write a class called Stack that will encapsulate a dynamically-allocated array of elements of a generic data type. A driver program is provided for this assignment to test your implementation. You don't have to write the tests. Program You will need to write a single template class for this...
This project is divided into 3 parts: Part 1. Create a new project and download the arrayList and unorderedArrayList templates that are attached. Create a header file for your unorderedSet template and add it to the project. An implementation file will not be needed since the the new class will be a template. Override the definitions of insertAt, insertEnd, and replaceAt in the unorderedSet template definition. Implement the template member functions so that all they do is verify that the...
Write a C++ program to implement Queue ADT using singly linked structure. The program includes the following: Define the Queue class template in the header file QueueLinked.h. // QueueLinked.h #ifndef QUEUE_H #define QUEUE_H #include <iostream> using namespace std; template <typename T> class Queue { public: // Constructor Queue(); //Desctructor ~Queue(); // Makes the queue to the empty state. void make_empty(); // Checks if the queue is empty. bool empty() const; // Inserts item at the end of the queue. void...
Hello, I have some errors in my C++ code when I try to debug it.
I tried to follow the requirements stated below:
Code:
// Linked.h
#ifndef INTLINKEDQUEUE
#define INTLINKEDQUEUE
#include <iostream>
usingnamespace std;
class IntLinkedQueue
{
private: struct Node {
int data;
Node *next;
};
Node *front; // -> first item
Node *rear; // -> last item
Node *p; // traversal position
Node *pp ; // previous position
int size; // number of elements in the queue
public:
IntLinkedQueue();...