Use CodeBlocks to implement the class definition of the Professor class. need th
ID: 3579368 • Letter: U
Question
Use CodeBlocks to implement the class definition of the Professor class. need the following classes:
1. Person
class Person {
public:
// set name to default value, address to default value, and contact to default value
Person();
// use setters and getters to set the firstName, middleName, and lastName
Person(Name n, Address addr, Contact c);
// setter for name
void setName(Name n);
// setter for address
void setAddress(Address addr);
// setter for contact
void setContact(Contact cont);
// getter for name
Name getName() const;
// getter for address
Address getAddress() const;
// getter for contact
Contact getContact() const;
private:
Name name;
Address address;
Contact contact;
};
2. Name
class Name {
public:
// set firstname to empty string, middleName to to empty string,
// and lastName to empty string
Name();
// use setters and getters to set the firstName, middleName, and lastName
Name(string firstName, string middleName, string lastName);
// setter for first name
void setFirstName(string fname);
// setter for middle name
void setMiddleName(string mname);
// setter for last name
void setLastName(string lname);
// getter for first name
string getFirstName() const;
// getter for middle name
string getMiddleName() const;
// getter for last name
string getLastName() const;
private:
string firstName;
string middleName;
string lastName;
};
3. Address
class Address{
public:
// set all string variables to empty string and int variables to 0
Address();
// use setters to initialize each member
Address( string address1,string address2,
string ct, string st, string zip, string ctry);
// setter for address line 1
void setAddressLine1(string address1);
// setter for address line 2
void setAddressLine2(string address2);
// setter for city
void setCity(string c);
// setter for state
void setState(string st);
// setter for zip
void setZipcode(string zip);
// setter for zountry
void setCountry(string ctry);
// getter for address line 1
string getAddressLine1() const;
// getter for address line 2
string getAddressLine2() const;
// getter for city
string getCity() const;
// getter for state
string getState() const;
//getter for zipcode
string getZipcode() const;
// getter for country
string getCountry() const;
private:
string addressLine1;
string addressLine2;
string city;
string state;
string zipcode;
string country;
};
4. Contact
class Contact {
public:
// set firstname to empty string, middleName to to empty string,
// and lastName to empty string
Contact();
// use setters and getters to set mobile, and email address
Contact(string mobile, string email);
// setter for first name
void setMobile(string mobile);
// setter for middle name
void setEmail(string email);
// getter for first name
string getMobile() const;
// getter for middle name
string getEmail() const;
private:
string mobile;
string email;
};
5. Course
6. Professor
Here is the description of the new classes:
The Course class.
-----Course--------
- id : int
- name : string
- section : string
+ Course()
+ Course(int, string, string)
+ print() : void
+ getId() : int
+ setId(int) : void
+ getName() : string
+ setName(string) : void
+ getSection() : string
+ setSection(string) : void
Notes:
Default Constructor: Initialize id to 0, name and section to empty string
Overloaded Constructor: Initialize id to another course id, name to another course name, and section to another course section (all three elements passed as parameters).
Print: Displays the course id, course name, and course section.
The Professor class (derived class from Person class).
------Professor----
- employeeId : int
- courses[10] : Course
+ Professor()
+ Professor(Name, Address, Contact, int, Course[])
+ print() : void
+ getEmployeeId() : int
+ setEmployeeId(int) : void
+ getCourses(Course[]) : void
+ setCourses(Course[])) : void
Notes:
Name, address and contact are inherited from Person class
Use composition to have an array of (Course) objects; store up to 10 elements.
Default Constructor:
1. Invokes the default constructor of the parent class, and
2. Initializes employee id to 0.
Overloaded Constructor:
1. Invokes the overloaded constructor of the parent class, and
2. Initializes employee id to 0,
Print: Display the following data:
1. Person name (no need to display the address nor contact info),
2. Employee id, and
3. The list of courses assigned/taught by this professor. To print each course, you will need to invoke the print member function of the Course class.
In the main function:
Creating the Array of Courses
1. Use the overloaded constructor to create 3 objects of type Course [*]
2. Create an array of objects of type Course class
3. Add the three courses in the array
Creating the Professor Object
4. Use the overloaded constructor to create 1 object of type Name [*]
5. Use the default constructor to create 1 object of type Professor
6. From the object in #5, use the setter for Name to set the object in #4
7. From the object in #5, use the setter for Courses to set the array of objects in #3
8. From the object in #5, use the member function print to show the professor info and course details.
[*] Hard-coded values, no need to use input statements.
Sample Run:
Professor Name: Joe Joee
Employee Id: 983-78-544
Courses:
CSS – 1 0205 Introduction to Programming
CSS – 2A 7174 Object Oriented Programming
CSS- 7 1567 Discrete Math
Explanation / Answer
#include <iostream>
02
#include <cstdlib> // for random variety functions
03
#include <ctime> // for clock functions
04
using namespace std;
05
06
#include "DynQueue.h" // needs queue ADT
07
08
double randVal(); // model for random generation perform
09
10
const double NORTH_SOUTH_ARRIVE_FREQ = one.0/10.0; // Prob. of automotive inward every second
11
const double EAST_WEST_ARRIVE_FREQ = one.0/30.0; // Prob. of automotive inward every second
12
const int REDLIGHTON = 120;
13
const int GREENLIGHTON = 360;
14
15
const int SIM_TIME = 3600; // In seconds
16
const int> 17
18
int main()
19
discovered for random variety generator
21
srand(time(0)); // Set seed for random variety to clock
22
23
24
// Variables
25
DynQueue<int> northSouth_q; // north/south queue
26
DynQueue<int> eastWest_q; // east/west queue
27
28
int time; // clock for simulation
29
int i;
30
31
32
int northSouthCars = 0; // Total arrival counter
33
int EastWestCars = 0; // Total departures counter
34
35
// SIMULATION
36
for (time=1;time <= SIM_TIME; time++)
37
42
if (randVal() <= EAST_WEST_ARRIVE_FREQ) // New departure
43
46
//commented out as a result of i detected that i need the employment of (is empty) however it'd still
47
//i will see however its not getting to work as a result of if it absolutely was not empty it'd still dequeue nothing, or try to
48
// for (i = 0; i <= GREENLIGHTON; i++)
49
//
53
//
54
// for (i = 0; i <= GREENLIGHTON; i++)
55
//
59
60
61
62
}
63
}
64
65
/*************************************************************************/
66
/* This functions returns as random variety between zero.0 and 1.0 */
67
/*************************************************************************/
68
double randVal()
69
come back double(rand()) / double(RAND_MAX);
71
}
template <class ItemType>
002
class DynQueue
003
;
010
011
NodeType *front;
012
NodeType *rear;
013
int numItems;
014
public:
015
DynQueue();
016
~DynQueue();
017
void enqueue(ItemType);
018
ItemType dequeue();
019
bool isEmpty();
020
bool isFull();
021
void clear();
022
};
023
024
#endif
025
026
//==================================================
027
//Implementation for Dynamic Queue category
028
//==================================================
029
030
#include <iostream>
031
using namespace std;
032
033
//************************
034
// creator *
035
//************************
036
037
template <class ItemType>
038
DynQueue<ItemType>::DynQueue()
039
044
045
//************************
046
// Destructor *
047
//************************
048
049
template <class ItemType>
050
DynQueue<ItemType>::~DynQueue()
051
054
055
//********************************************
056
// perform enqueue inserts the worth in num *
057
// at the rear of the queue. *
058
//********************************************
059
060
template <class ItemType>
061
void DynQueue<ItemType>::enqueue(ItemType item)
062
073
else
074
078
numItems++;
079
}
080
081
//**********************************************
082
// perform dequeue removes the worth at the *
083
// front of the queue, and copies it into num. *
084
// PRECONDITION: Queue isn't empty *
085
//**********************************************
086
087
template <class ItemType>
088
ItemType DynQueue<ItemType>::dequeue()
089
temporary worker = front;
095
front = front->next;
096
delete temp;
097
numItems--;
098
come back returnItem;
099
}
100
101
//*********************************************
102
// perform isEmpty returns true if the queue *
103
// is empty, and false otherwise. *
104
//*********************************************
105
106
template <class ItemType>
107
bool DynQueue<ItemType>::isEmpty()
108
standing = false;
113
else
114
standing = true;
115
come back status;
116
}
117
118
//****************************************************
119
// Member perform isFull is assumed to be false. *
120
// Tailor to native operational atmosphere. *
121
//****************************************************
122
123
template <class ItemType>
124
bool DynQueue<ItemType>::isFull()
125
{
126
come back false;
127
}
128
129
//********************************************
130
// perform clear dequeues all the weather *
131
// within the queue. *
132
//********************************************
133
134
template <class ItemType>
135
void DynQueue<ItemType>::clear()
136
worth = dequeue();
141
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.