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

2) Complete the parameterized constructor that takes arguments that are used to initialize ALL class’s member...
2) Complete the parameterized constructor that takes arguments that are used to initialize ALL class’s member variables. [2 points] 3) Complete the code for getTitle() member function. The function returns the title of the Song. [1 point] 4) Complete the code for getDurationSec() member function, which returns the duration in seconds instead of minutes. [2 points] 5) Write member function definitions for three member functions below: [3 points] void setTitle(string t); //set title to t void setAuthor(Author a); //set author...
(In C++) Task 1: Implement a code example of Constructor Chaining / Constructor Overloading. Make sure...
(In C++) Task 1: Implement a code example of Constructor Chaining / Constructor Overloading. Make sure to label class and methods with clear descriptions describing what is taking place with the source code. Attach a snipping photo of source code and output
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...
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...
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;...
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. 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:+<>______( _____ : ______)
# 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. 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...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT