i. Create an array of instructors using the template and print all the items of the array. ii. Create an array of textbooks using the template and print all the items of the array. iii. Create a Course object with the following data and print the object. Title: “Programming Technique II"

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please solve the following problem by using the following code-

#include <iostream>
#include <string>
using namespace std;

class Instructor
{
private:
    string firstName;
    string lastName;
    string office; // Office Room Number e.g., N28A-L303

public:
    Instructor(string firstName, string lastName, string office)
    {
        this->firstName = firstName;
        this->lastName = lastName;
        this->office = office;
    }

    void print() const
    {
        cout << "First name: " << firstName << endl;
        cout << "Last name: " << lastName << endl;
        cout << "Office number: " << office << endl;
    }
};

class TextBook
{
private:
    string title;     // Book title
    string author;    // Author name
    string publisher; // Publisher name
public:
    TextBook(string title, string author, string publisher)
    {
        this->title = title;
        this->author = author;
        this->publisher = publisher;
    }

    void print() const
    {
        cout << "Title: " << title << endl;
        cout << "Author: " << author << endl;
        cout << "Publisher: " << publisher << endl;
    }
};

class Course
{
private:
    string name;
    Instructor *instructor;
    TextBook *textBook;

public:
    Course(string name)
    {
        this->name = name;
        instructor = NULL;
        textBook = NULL;
    }

    void setInstructor(Instructor *i) { instructor = i; }
    void setTextBook(TextBook *b) { textBook = b; }

    void print() const
    {
        cout << "Course name: " << name << endl;
        cout << "Instructor Information:" << endl;
        if (instructor) instructor->print();
        cout << endl;

        cout << "\nTextbook Information:" << endl;
        if (textBook) textBook->print();
    }
};

//? You are not expected to modify any of the above classes.

// Todo: Question 2(b) Define the class template


int main()
{
    // Todo: Question 2(c)
    
    // Data for the instructors and textbooks:
    //
    // "Ahmad", "Kamal", "N28-L305"
    // "Mellisa", "Wong", "D06-105"
    // "Ali", "Hassan";
    //
    // "Object-Oriented Programming Approach Using C++", "Gilberg", "Springer Publication"
    // "Introduction to Functional Programming with TypeScript", "Samantha", "Oxford Press"
    

    cout << "LIST OF INSTRUCTORS:" << endl << endl;
    cout << "-------------------------------------------------------"<< endl << endl;

    cout << "LIST OF TEXTBOOKS:" << endl << endl;
    cout << "-------------------------------------------------------"<< endl << endl;

    cout << "COURSE INFORMATION:" << endl << endl;

    cin.get();

    return 0;
}

Test the template in the main function of program2.cpp by accomplishing the
following tasks. See expected output in Figure 2.
i. Create an array of instructors using the template and print all the items of the
array.
ii. Create an array of textbooks using the template and print all the items of the
array.
iii. Create a Course object with the following data and print the object.
Title: “Programming Technique II"
Instructor: the first item of the instructor array, created in c(i).
Textbook: the second item of the textbook array, created in c(ii).
Transcribed Image Text:Test the template in the main function of program2.cpp by accomplishing the following tasks. See expected output in Figure 2. i. Create an array of instructors using the template and print all the items of the array. ii. Create an array of textbooks using the template and print all the items of the array. iii. Create a Course object with the following data and print the object. Title: “Programming Technique II" Instructor: the first item of the instructor array, created in c(i). Textbook: the second item of the textbook array, created in c(ii).
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY