Question

In: Computer Science

Task 1: Implement the constructor for the Hostess struct. It must initialize all member variables, including...

Task 1:

Implement the constructor for the Hostess struct. It must initialize all member variables, including any arrays. There is another function that performs initialization. You must change the program so that the object’s initialization is done automatically, i.e. no explicit call is needed for an initialization function.

#ifndef HOSTESS_H
#define HOSTESS_H
#include "Table.h"
#include <iostream>

struct Hostess{

    void Init();
    void PlaceArrivalInQueue(int arrivals);
    void ShiftLeft();
    void Print(int hour, int minute, int arrivals);

    int GetNumTables(){return numTables;}
    int Seat(int table, int time);
    int CheckAvail();

    int totalServed;
    int currentCustomers;
    int queue_size;
    int numTables;

    Table tables[30];
    int queue[15];
};
#endif // HOSTESS_H

Solutions

Expert Solution

#ifndef HOSTESS_H
#define HOSTESS_H
#include "Table.h"
#include <iostream>

struct Hostess{

    void Init();
    void PlaceArrivalInQueue(int arrivals);
    void ShiftLeft();
    void Print(int hour, int minute, int arrivals);

    int GetNumTables(){return numTables;}
    int Seat(int table, int time);
    int CheckAvail();

    int totalServed;
    int currentCustomers;
    int queue_size;
    int numTables;

    Table tables[30];
    int queue[15];
public:
    Hostess(int totalServed,int currentCustomers,int queue_size,int numTables,int queue[])
    {
        this->totalServed=totalServed;
        this->currentCustomers=currentCustomers;
        this->queue_size=queue_size;
        this->numTables=numTables;

        for(int i=0;i<15;i++)
        {
            this->queue[i]=queue[i];
        }


        for(int i=0;i<30;i++)
        {
            this->tables[i]=Table();
        }



    }
};
#endif // HOSTESS_H

int main()
{

}

Related Solutions

Step 1: Extend the dispenserType class per the following specifications. Add a parameterized constructor to initialize...
Step 1: Extend the dispenserType class per the following specifications. Add a parameterized constructor to initialize product name (name), product cost (cost) and product quantity (noOfItems). This constructor will be invoked from main.cpp. One such call to this constructor will look like: dispenserType sanitizer("hand sanitizer", 50, 100); Add the declaration and definition of this parameterized constructor to .h and .cpp files. Step2: Define a new class, cashRegister. Start by creating cashRegister.h and cashRegister.cpp files. Be sure to update your CMakeLists.txt...
class DoubleLinkedList { public: //Implement ALL following methods. //Constructor. DoubleLinkedList(); //Copy constructor. DoubleLinkedList(const DoubleLinkedList & rhs);...
class DoubleLinkedList { public: //Implement ALL following methods. //Constructor. DoubleLinkedList(); //Copy constructor. DoubleLinkedList(const DoubleLinkedList & rhs); //Destructor. Clear all nodes. ~DoubleLinkedList(); // Insert function. Returns true if item is inserted, // false if the item it a duplicate value bool insert(int x); // Removes the first occurrence of x from the list, // If x is not found, the list remains unchanged. void remove(int x); //Assignment operator. const DoubleLinkedList& operator=(const DoubleLinkedList & rhs); private: struct node{ int data; node* next;...
Song struct to store the data for a single song (make it a private member), and you must have an array of Song structures as a member variable.
USE C++ Song struct to store the data for a single song (make it a private member), and you must have an array of Song structures as a member variable.Player(string name, float size) a constructor for the class. ’name' is a name for it'size' is a maximum capacity in Mb.addSong(string band, string title, string length, float size) a function for adding a new song.'band' is a name of the band'title' is a name of the song'length' is a time length of...
1. From the constructor, you infer that the name of the class containing the constructor must be_______ .
1. From the constructor, you infer that the name of the class containing the constructor must be_______ .2. Fill in the blanks so that the statement will instantiate a JButton object and assigns it to variable of JButton type:JButton btn= _______ ("OK");3. Fill in the blanks to complete the description of the constructor in the corresponding UML class diagram:+<>______( _____ : ______)
Declare a Song struct to store the data for a single song (make it a private member), and you must have anarray of Song structures as a member variable.
USE C++ Declare a Song struct to store the data for a single song (make it a private member), and you must have anarray of Song structures as a member variable.Player(string name, float size) a constructor for the class. ’name' is a name for it'size' is a maximum capacity in Mb.addSong(string band, string title, string length, float size) a function for adding a new song.'band' is a name of the band'title' is a name of the song'length' is a time length...
1. A constructor is a special Class member method. It is automatically called when an object...
1. A constructor is a special Class member method. It is automatically called when an object of the class is created. It can also be called more than once after the object is created. 2. In Java, the new operator is used to create an instance/object of a class in the heap. 3. A reference variable is a memory location contains an address of an object stored in the stack. 4. Encapsulation and abstraction are both the pillars of Object-Oriented...
# List the two private member variables (including name and functionality) in the node class. #Write...
# List the two private member variables (including name and functionality) in the node class. #Write a general pattern for a loop statement that traverses all the nodes of a linked list
1. Implement a public method named initialize. It takes a twodimensional square array of integers...
1. Implement a public method named initialize. It takes a two dimensional square array of integers namedarray as a parameter. It initializes all of the elements of the array to the sum of their indices except for themajor diagonal (upper left to lower right) where each element is initialized to -1. (For testing use a 4X4 or5X5 array and have the application print out the array in 2 dimension format.2. Implement a method named totals that takes a two dimensional...
(1) default constructor which initalizes all the coefficients to 0 (2) a constructor that takes three...
(1) default constructor which initalizes all the coefficients to 0 (2) a constructor that takes three parameters public QuadraticExpression(double a, double b, double c) (3) a toString() method that returns the expression as a string. (4) evaluate method that returns the value of the expression at x public double evaluate(double x) (5) set method of a, b, c public void setA(double newA) public void setB(double newB) public void setC(double newC) (6) public static QuadraticExpression scale( double r, QuadraticExpression q) returns...
PYTHON ASSIGNMENT Problem: (1) The  __init__ method should initialize the values of the instance variables. Here is...
PYTHON ASSIGNMENT Problem: (1) The  __init__ method should initialize the values of the instance variables. Here is the beginning of __init__: def __init__(self, the_hr, the_min, the_sec): self.hr = the_hr # Also initialize min and sec. (2) Include a __str__ method that returns the current state of the clock object as a string. You can use the string format method format like this: return "{0:02d}:{1:02d}:{2:02d}".format(self.hr, self.min, self.sec) (3) When the tick method is executed, add one to sec. If the resulting value...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT