Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need these tasks completed //Interface File for Computer //Header file Compute

ID: 644066 • Letter: I

Question

I need these tasks completed

//Interface File for Computer
//Header file Computer.h: This is the INTERFACE for the class Computer.
//This type models a computer in the Lab, and keep track of who is logged in

///////////////// NO TASKS

#ifndef COMP_H
#define COMP_H

#include
#include

namespace csc161
{
   class Computer_T
   {
   public:

       //Returns true if comp2 and comp2 are compatible; otherwise, returns false
       friend bool operator ==(const Computer_T& comp1, const Computer_T& comp2);
      
       // Default constructor
       Computer_T();          
              
   // Default copy constructor      
       Computer_T(const Computer_T& p_computer);

       //Initializes a Computer of a given model.
       Computer_T(string p_model);
      

       // Destructor
       ~Computer_T();
      
              
       void setModel(string p_model);
       string getModel();

       void reboot();
       // Simulates a computer reboot
       // Postcondition: Computer is online and available
      
       void putOffline();
       // Takes computer offline
       // Postcondition: Computer is offline
      
       void putOnline();
       // Puts computer online
       // Postcondition: Computer is online
      
       bool isAvailable();
       //Returns true is computer is online and available

       int whoIsLoggedIn();
       //Returns student ID

       void signon(int p_student_id);
       //Precondition: Computer is online and available
       //Postcondition: Student is logged on

       void signoff();
       //Precondition:
       //Postcondition: Student is logged on

       void virtual whatOSAmI();
      
       friend istream& operator >>(istream& ins, Computer_T& the_object);
       //Overloads the >> operator for input values of type Computer.
       //Precondition: If ins is a file input stream, then ins has already been
       //connected to a file.

       friend ostream& operator <<(ostream& outs, const Computer_T& the_object);
       //Overloads the << operator for output values of type Computer.
       //Precondition: If outs is a file output stream, then outs has already been
       //connected to a file.
   private:
       string model;
       bool online;
       bool available;
       int student_id;      
   };
  
   typedef Computer_T* ComputerPtr;
  
   class WindowsComputer_T : public Computer_T {
       void virtual whatOSAmI() override;
   };

   class LinuxComputer_T : public Computer_T {
       void virtual whatOSAmI() override;
   };

   class AppleComputer_T : public Computer_T {
       void virtual whatOSAmI() override;
   };

} // namespace csc161
#endif //COMP_H

----------------------------------

//Header file Department.h
//This is the INTERFACE for the class Department_T.
//This type models a Department, with several Labs in it

///////////////// 7 TASKS - a total of 40 points

#ifndef DPT_H
#define DPT_H

#include
#include

namespace csc161
{
   class Department_T
   {
   public:

       /////////////////// TASK 1 (5 points)
       // Declare a friend == overloaded operator
      


       /////////////////// END TASK 1


       /////////////////// TASK 2 (5 points)
       // Define a default constructor
      
      
       /////////////////// END TASK 2


       Department_T(std::string p_dep_name, unsigned int p_dep_size, string p_lab_names[], int p_lab_sizes[]);
       //Initializes a Department with a given name and number of labs
      

       /////////////////// TASK 3 (5 points)
       // Define a default copy constructor. Use case: Department moves to another facility
      

      
       /////////////////// END TASK 3
      

       /////////////////// TASK 4 (5 points)
       // Define a destructor for Department_T object.
      

         

       /////////////////// END TASK 4

       /////////////////// TASK 5 (10 points)
       // Define function members to "get" and "set" Department name. Qualify 'string' with 'std' namespace

  

       /////////////////// END TASK 5


       unsigned int getDepSize() const;
       //Returns number of labs in a Department

       void setDepSize (unsigned int p_dep_size);
       //Sets lab size

       LabPtr getLabs();
       // Returns pointer to array of Labs

       friend ostream& operator <<(ostream& outs, const Department_T& the_object);
       //Overloads the << operator for output values of type Department_T.
       //Precondition: If outs is a file output stream, then outs has already been
       //connected to a file.
      
   private:
       std::string dep_name;
       unsigned int dep_size;

       /////////////////// TASK 6 (5 points)
       // Declare "dep_labs" variable of type LabPtr (defined in Lab.h)
      


       /////////////////// END TASK 6
      
   };

   /////////////////// TASK 7 (5 points)
   // Use 'typedef' to define a new type called DepPtr which is a pointer to Department_T
  
  

   /////////////////// END TASK 7

} // namespace csc161
#endif //DEP_H

-----------------------------

//Header file Lab.h
//This is the INTERFACE for the class Lab_T.
//This type models a Lab, with several Computers in it

///////////////// NO TASKS

#ifndef LAB_H
#define LAB_H

#include
#include

namespace csc161
{
   class Lab_T
   {
   public:
       friend bool operator ==(const Lab_T& lab1, const Lab_T& lab2);
       //Returns true if lab2 and lab2 are compatible; otherwise, returns false.

       Lab_T();
       //Initializes a default empty Lab.

       Lab_T(std::string p_lab_name, unsigned int p_lab_size);
       //Initializes a lab with a given name and size

       Lab_T(const Lab_T& p_lab);
       // Copy constructor for Lab_T object. Use case: lab moves to another facility
      
       ~Lab_T();
       // Destructor
      
       std::string getLabName() const;
       //Returns lab name

       void setLabName(std::string p_lab_name);
       //Sets lab name

       unsigned getLabSize() const;
       //Returns lab size

       void setLabSize(unsigned p_lab_size);
       //Sets lab size

       ComputerPtr getComputers();
       // Returns pointer to array of computers

       // Create array of computers for a lab
       void addComputers(int p_lab_size);

       friend ostream& operator <<(ostream& outs, const Lab_T& the_object);
       //Overloads the << operator for output values of type Lab_T.
       //Precondition: If outs is a file output stream, then outs has already been
       //connected to a file.
      
   private:
       std::string lab_name;
       unsigned int lab_size;
       ComputerPtr computers; // Points to array of Computers      
   };

   // Type definition
   typedef Lab_T* LabPtr;  

} // namespace csc161
#endif //LAB_H

------------------

//Implementation File for Computer.cpp
//Header file is in Computer.h


///////////////// NO TASKS

using namespace std;
#include
#include
#include "Computer.h"

namespace csc161
{
   const int OPEN = -1;

   // Returns true if comp2 and comp2 are compatible; otherwise, returns false.
   bool operator ==(const Computer_T& comp1, const Computer_T& comp2)
   {      
       return (comp1.model == comp2.model);      
   };  
      
   // Contructor to set the computer model; look up the member variable to set
   Computer_T::Computer_T(string p_model) {
       model = p_model;  
   };  
          
   // Copy constructor construcst an object that is a copy of the object passed in
   Computer_T::Computer_T(const Computer_T& p_computer)
   {
       model = p_computer.model;
      >        available = p_computer.available;
       student_id = p_computer.student_id;
   };
  
   // Default constuctor thatinitializes all the members:
   Computer_T::Computer_T() {  
       model = "";
      >        available = false;
       student_id = 0;  
   };
      
   // Destructor
   Computer_T::~Computer_T() {};  

   // Reboots computer
   void Computer_T::reboot()
       //Postcondition: Computer is online and available
   {
      >        available = true;
       student_id = OPEN;      
   };

   void Computer_T::setModel(string p_model) {
       model = p_model;
   }
      
   string Computer_T::getModel() {
       return model;
   }

   // Simulates taking computer offline
   // Postcondition: Computer is offline
   void Computer_T::putOffline() {  
      >    };
  
   // Simulates taking computer online
   // Postcondition: Computer is online
   void Computer_T::putOnline() {  
  >    };
  

   bool Computer_T::isAvailable() { return available; };
       //Returns true is computer is online and available

   int Computer_T::whoIsLoggedIn() { return student_id; };
       //Returns student ID

   void Computer_T::signon(int p_student_id)
       //Precondition: Computer is online and available
       //Postcondition: Student is logged on
   {
       available = false;
       student_id = p_student_id;
   };

   void Computer_T::signoff()
   //Precondition:
   //Postcondition: Student is logged on
   {
       student_id = OPEN;
       available = true;
   };

   void Computer_T::whatOSAmI() {};

   istream& operator >>(istream& ins, Computer_T& the_object)
       //Overloads the >> operator for input values of type Computer.
       //Precondition: If ins is a file input stream, then ins has already been
       //connected to a file.
   {
       ins >> the_object.model;
       return ins;
   }

   ostream& operator <<(ostream& outs, const Computer_T& the_object)
   //Overloads the << operator for output values of type Computer.
   //Precondition: If outs is a file output stream, then outs has already been
   //connected to a file.
   {
       {
           if (the_object.student_id == OPEN)
               outs << "Open ";
           else
               outs << the_object.student_id;
          
           return outs;
       }

   }

      
   void WindowsComputer_T::whatOSAmI() {
       cout << "I am a Windows computer" << endl;
   }

   void LinuxComputer_T::whatOSAmI() {
       cout << "I am a Linux computer" << endl;
   }

   void AppleComputer_T::whatOSAmI() {
       cout << "I am an Apple computer" << endl;
   }

} // namespace csc161

--------------------------

// *********************************************************************
// This program model a Department with computer labs.
// A Department can have multiple labs, stored in a dynamic array
// Each Lab_T object holds a dynamic array of Computer_T objects,
// that is of size for however many computers are in that lab.
//
// *********************************************************************


///////////////// 3 TASKS - a total of 30 points. And 1 Extra Credit TASK worth 10 points

#include
#include
#include

using namespace std;

#include "Computer.h"
#include "Lab.h"
#include "Department.h"
using namespace csc161;


// Constants
const int NUMLABS = 4;

///////////////////// FUNCTIONS PROTOTYPES

// The functions below correspond to the User Menu options
void login(Department_T& p_dep);
void logoff(Department_T& p_dep);
void search(Department_T& p_dep);

// This is a utility function that prints the status of the computers in labs
void showLabs(Department_T& p_dep);

// A utility function to enter user ID
int enterID();

// A utility function to enter Lab number
int enterLabNumber(Department_T& p_dep);

// A utility function to enter Computer number
int enterComputerNumber(Department_T& p_dep);

// A utility function that validates student ID entered by a user.
// It returns true if ID is valid, and false if it is not valid
bool validID(int p_id);

/////////////////////////////////////// FUNCTIONS IMPLEMENTATIONS

/////////////////// TASK 13 (10 points)
// Write a utility function called "validID" declared above
// Fix(!) the code below so that a valid ID is a positive, odd, 5-digit integer number.

bool validID(int p_id) {
   return((p_id > 0) && (p_id <= 99999));
};

/////////////////// END TASK 13


int enterID() {
   int id = -1;
   while (!validID(id))
   {
       cout << "Enter an odd 5 digit ID number of the user logging in:" << endl;
       cin >> id;
   }
   return id;
};

/////////////////// TASK 14 (10 points)
// Write a function called "enterLabNumber" declared above that encapsulates the functionality of
// entering a Lab Number by a user, currently coded in the "login" function.
// The function should take a reference to a Department and return an integer
// Then replace the relevant code in the "login" block with that function call


/////////////////// END TASK 14

/////////////////// TASK 15 (10 points)
// Write a function called "enterComputerNumber" declared above that encapsulates the functionality of
// entering a Computer Number by a user, currently coded in the "login" function.
// The function should take a reference to a Department and return an integer
// Then replace the relevant code in the "login" block with that function call

/////////////////// END TASK 15


// ======================
// showLabs:
// Displays the status of all labs (who is logged into which computer).
// ======================
void showLabs(Department_T& p_dep)
{
   unsigned i, j;
  
   cout << "Department:" << p_dep.getDepName() << endl;
   cout << "Lab # Computer Stations" << endl;
   for (i=0; i < p_dep.getDepSize(); i++)
   {
       cout << i+1 << " ";
      
       // Iterate through all the computers in a Lab and print its status
       for (j = 0; j < (p_dep.getLabs()[i]).getLabSize(); j++)
       {
           cout << (j+1) << ": ";

           ///////////////////TASK X (10 points) EXTRA CREDIT
           // Use the << operator on a Computer_T object to print the info about each computer.
           // The challenge is to properly reference a 'j' computer in 'i' lab

          


           /////////////////// END TASK X

       }
       cout << endl;
   }
   cout << endl;
   return;
}

// ======================
// login:
// Simulates a user login by asking for the login info from
// the console.
// ======================
void login(Department_T& p_dep)
{
   int id = -1, lab = -1, num = -1;

   while (!validID(id))
   {
       cout << "Enter the 5 digit ID number of the user logging in:" << endl;
       cin >> id;
   }
   while ((lab < 0) || (lab > p_dep.getDepSize()))
   {
       cout << "Enter the lab number the user is logging in from (1-" <<
           NUMLABS << "):" << endl;
       cin >> lab;
   }
   while ((num < 0) || (num >(p_dep.getLabs()[lab - 1]).getLabSize()))
   {
       cout << "Enter computer station number the user is logging in to " <<
           "(1-" << (p_dep.getLabs()[lab - 1]).getLabSize() << "):" << endl;
       cin >> num;
   }

   // Check to see if this station is free
   if (!(p_dep.getLabs()[lab - 1]).getComputers()[num - 1].isAvailable())
   {
       cout << "ERROR, user " << (p_dep.getLabs()[lab - 1]).getComputers()[num - 1].whoIsLoggedIn() <<
           " is already logged into that station." << endl;
       return;
   }
   // Assign this station to the user
   (p_dep.getLabs()[lab - 1]).getComputers()[num - 1].signon(id);
   return;
}

// ======================
// logoff:
// Searches through the arrays for the input user ID and if found
// logs that user out.
// ======================
void logoff(Department_T& p_dep)
{
   int id = -1;
   unsigned i, j;

   id = enterID();

   for (i = 0; i< p_dep.getDepSize(); i++)
   {
       for (j = 0; j< (p_dep.getLabs()[i]).getLabSize(); j++)
       {
           if ((p_dep.getLabs()[i]).getComputers()[j].whoIsLoggedIn() == id)
           {
               // Log off the user
               ((p_dep.getLabs()[i]).getComputers())[j].signoff();
               cout << "User " << id << " is logged off." << endl;
               return;
           }
       }
   }
   cout << "That user is not logged in." << endl;
   return;
}


// ======================
// search:
// Searches through the arrays for the input user ID and if found
// outputs the station number.
// ======================
void search(Department_T& p_dep)
{
   int id = -1;
   unsigned i, j;

   // Enter user ID
   id = enterID();

   for (i = 0; i    {
       for (j = 0; j < (p_dep.getLabs()[i]).getLabSize(); j++)
       {
           if ((p_dep.getLabs()[i]).getComputers()[j].whoIsLoggedIn() == id)
           {
               cout << "User " << id << " is in lab " << i+1 <<
                   " at computer " << j+1 << endl;
               return;
           }
       }
   }
   cout << "That user is not logged in." << endl;
   return;
}


// ======================
// main function
// ======================
int main()
{
   int labSizes[NUMLABS]={5,6,4,3};   // Number of computers in each lab
   string labNames[NUMLABS] = { "Lab-A", "Lab-B", "Lab-C", "Lab-D" }; // Names of the labs
      
   // Create Department "IT" with 4 labs
   //Department_T *ccd_dep = new Department_T("IT", 4, labNames, labSizes);
   Department_T ccd_dep("IT", 4, labNames, labSizes);

   int choice = -1;
   // Main Menu
   while (choice != 0)
   {
       cout << endl;
       showLabs(ccd_dep);

       cout << "MAIN MENU" << endl;
       cout << "0) Quit" << endl;
       cout << "1) Simulate login" << endl;
       cout << "2) Simulate logoff" << endl;
       cout << "3) Search" << endl;

       cin >> choice;

       switch (choice) {

       case 1:
           login(ccd_dep);
           break;
       case 2:
           logoff(ccd_dep);
           break;
       case 3:
           search(ccd_dep);
           break;
       default:
           break;
       };
   }

   // Test harness for a copy constructor
   Lab_T copyOfLab3(ccd_dep.getLabs()[2]); // copy 3rd lab
   cout << copyOfLab3;

   // Test harness for polymorphism
   WindowsComputer_T winBox;
   LinuxComputer_T linuxBox;
   AppleComputer_T appleBox;

   ComputerPtr computer[3] = { &winBox, &linuxBox, &appleBox };
   for (unsigned int j = 0; j < 3; j++) {
       computer[j]->whatOSAmI();
   }

   system("pause");

   return 0;
}

-------------------

//Implementation File for Department.cpp
//Header file Department.h:

///////////////// 5 TASKS - a total of 30 points

using namespace std;
#include
#include
#include

/////////////////// TASK 8 (5 points)
// A Department uses Labs and Computers, therefore we must include appropriate header files.


/////////////////// END TASK 8

#include "Department.h"

namespace csc161
{
   /////////////////// TASK 9 (5 points)
   // Write the body of this "==" operator
   // Returns true if Departments are the same size; otherwise returns false.
   bool operator ==(const Department_T& dep1, const Department_T& dep2)
   {
      


   };

   ////////////////// END TASK 9
  
   /////////////////// TASK 10 (5 points)
   // This constructor initializes a Department of a given name and with given number of labs
   // It sets the name for each Lab, based on the input array of lab names
   // Modify the code below to also set the size for each Lab, based on the input array of Lab sizes

   Department_T::Department_T(string p_dep_name, unsigned p_dep_size, string p_lab_names[], int p_lab_sizes[]) {
       assert(p_dep_size > 0);
       dep_name = p_dep_name;
       dep_size = p_dep_size;
       dep_labs = new Lab_T[p_dep_size];

       for (int i = 0; i < p_dep_size; i++) {
           dep_labs[i].setLabName(p_lab_names[i]);

           // Code goes here
          

           dep_labs[i].addComputers(p_lab_sizes[i]);
           for (int j = 0; j < p_lab_sizes[i]; j++) {
               dep_labs[i].getComputers()[j].reboot();
           }
       }          
   };
   ////////////////// END TASK 10
      
   //Copy constructor
   Department_T::Department_T(const Department_T& p_dep) {
      
   };
  
   //Initializes a default empty Department.
   Department_T::Department_T() {};

   Department_T::~Department_T() {
       delete [] dep_labs;
   };
      

   /////////////////// TASK 11 (10 points)
   // Define function members to "get" and "set" Department name. Look up the definition in the header file
   // Qualify "string" with "std" namespace
  


   /////////////////// END TASK 11

   //Returns Dep size
   unsigned int Department_T::getDepSize() const { return dep_size; };

   //Sets lab size
   void Department_T::setDepSize(unsigned int p_dep_size) {
       dep_size = p_dep_size;
   };
  
   // Returns pointer to array of computers
   LabPtr Department_T::getLabs() {
       return dep_labs;
   };
  

   ostream& operator <<(ostream& outs, const Department_T& the_object)
   //Overloads the << operator for output values of type Department_T.
   //Precondition: If outs is a file output stream, then outs has already been
   //connected to a file.
   {
       {

           /////////////////// TASK 12 (5 points)
           // Write code to output data from the Department_T object, in the format: ::
           // Example: IT::4

          

           /////////////////// END TASK 12

           return outs;
       }

   }
  
} // namespace csc161

-------------------

//Implementation File for Lab.cpp
//Header file Lab.h:

///////////////// NO TASKS

using namespace std;
#include
#include
#include

#include "Computer.h"
#include "Lab.h"

namespace csc161
{
   //Returns true if labs are the same size; otherwise returns false.
   bool operator ==(const Lab_T& lab1, const Lab_T& lab2)
   {
       return (lab1.getLabSize() == lab2.getLabSize());
   };
  
   //Initializes a lab of a given name and with given number of computers
   Lab_T::Lab_T(string p_lab_name, unsigned int p_lab_size) {
       assert(p_lab_size > 0);
       lab_name = p_lab_name;
       lab_size = p_lab_size;
       computers = new Computer_T[p_lab_size];

       // Computer is online and available
       for (unsigned int j = 0; j        {
           computers[j].reboot();      
       }
   };
      
   //Copy constructor
   Lab_T::Lab_T(const Lab_T& p_lab) {
       lab_name = p_lab.lab_name;
       lab_size = p_lab.lab_size;
       computers = new Computer_T[lab_size];
       for (unsigned int j = 0; j < lab_size; j++) {
           computers[j] = p_lab.computers[j];
       }
   };
  
   //Initializes a default empty Lab.
   Lab_T::Lab_T() {};

   Lab_T::~Lab_T() {
       delete [] computers;
   };
      
   //Returns lab name
   std::string Lab_T::getLabName() const { return lab_name; };


   //Sets lab name
   void Lab_T::setLabName(std::string p_lab_name) {
       lab_name = p_lab_name;
   };  

   //Returns lab size
   unsigned int Lab_T::getLabSize() const { return lab_size; };

   //Sets lab size
   void Lab_T::setLabSize(unsigned int p_lab_size) {
       lab_size = p_lab_size;
   };
  
   // Create array of computers for a lab
   void Lab_T::addComputers(int p_lab_size) {
       computers = new Computer_T[p_lab_size];
   }

   // Returns pointer to array of computers
   ComputerPtr Lab_T::getComputers() {
       return computers;
   };
  
   ostream& operator <<(ostream& outs, const Lab_T& the_object)
   //Overloads the << operator for output values of type Lab.
   //Precondition: If outs is a file output stream, then outs has already been
   //connected to a file.
   {
       {
           outs << the_object.lab_name << "::" << the_object.lab_size << endl;
           return outs;
       }
   }
  
} // namespace csc161

Explanation / Answer

Task 1:

int main{

int q,r,s;

q=5;

r=15;

s=30;

if (q < r & r < s);

cout << "Task complete!" << endl;

else ( q = 5);

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote