C++ PLEASE Lab on constant, static and inheritance (school.cpp) 1. You are going to make only one file that will have mu

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

C++ PLEASE Lab on constant, static and inheritance (school.cpp) 1. You are going to make only one file that will have mu

Post by answerhappygod »

C++ PLEASE
Lab on constant, static and inheritance
(school.cpp)
1. You are going to make only one file that will have multiple
classes and a client.
2. Create the following 3 classes with these data members.
Person (base classs) Which ones should be static data
members?
num (the total number of people created)
current_id (initialize it to 1000)
const ID (everybody at school has a unique ID such as a student
id, employee id, faulty id. ID should be set to current_id.)
first name (default value = unknown)
last name (default value = unknown)
SSN (111-222-3333) (default value = 000-00-0000)
email (default value = unknown)
Faculty (inherited from Person)
Department id (default value = -1)
Years at school (default value = -1)
Student (inherited from Person)
Major (default value = unknown)
Gpa (default value = -1.00)
Grade (F, J, S, N) = Freshman, Junior, Sophomore, Senior
(default value = ?)
3. Create a constructor in each class. When you create an
object, pass these arguments. Student s(“Mike”, “Smith”,
“111-22-3333”, [email protected], “CS”, 3.25, ‘S’); Faculty f(“Mike”,
“Smith”, “111-22-3333”, [email protected], 100, 5);
4. Make a function called printInfo() in each class to show all
the data members except for the static members.
5. Make a get function to return num.
6. Make a get function to return current_id.
7. In main, do the following.
Make an object from the person class using the default
values.
Make an object from the faculty class. Kathy, Ross, 222-33-4444,
[email protected], 100, 2
Make an object from the student class. Tom, Lopez, 333-44-5555,
[email protected], CS, 3.33, J
Call printInfo() to check each object’s info. à Double check
their IDs. Do they make sense?
Check the value of num. à Does the output make sense to you?
Check the value of current_id. à Does the output make sense to
you?
We will make a bigger main using virtual functions in the next
lab.
school_virtual.cpp
Make a copy of school.cpp and name it school_virtual.cpp
Get an input file called campus.dat from my public
directory.
3 Meg Ryan 666-44-5555 [email protected] MATH 3.75 J
2 Sophie Watkins 222-11-4444 [email protected] 110 15
1 Mike Smith 111-22-3333 [email protected]
3 Bob Lopez 333-44-5555 [email protected] CS 3.25 S
2 Kathy Ross 222-33-4444 [email protected] 100 5
1 means Person
2 means Faculty
3 means Student
Make a function called readData to make a linked list of all the
people from the input file. See the picture on the bottom. The
element field points to an Person, Faculty or Student object.
Make a c-stand-alone function called display (created in a
client. not a member function of any classses) to show the
information about all the people by calling printInfo(). Don’t call
LL::printAll() since this would display memory addresses (the
element of each node is an address ).
How do we traverse the list in the client?
Add ONLY the following member functions and an exception class
to LL_T.
getFront()
getRear()
getNext(??? p ){ if p is null, throw an OutOfBoundary exception
}
exception class OutOfBoundary
Make a c-stand-alone function called sort to sort all the people
by SSN using the selection sort algorithm. You might want to check
your selectionSortAll.cpp. Requirement: Don’t overwrite data inside
a Person, Faculty or Student object. Instead swap pointers
(addresses).
C Please Lab On Constant Static And Inheritance School Cpp 1 You Are Going To Make Only One File That Will Have Mu 1
C Please Lab On Constant Static And Inheritance School Cpp 1 You Are Going To Make Only One File That Will Have Mu 1 (47.64 KiB) Viewed 71 times
C Please Lab On Constant Static And Inheritance School Cpp 1 You Are Going To Make Only One File That Will Have Mu 2
C Please Lab On Constant Static And Inheritance School Cpp 1 You Are Going To Make Only One File That Will Have Mu 2 (58.08 KiB) Viewed 71 times
Student obj Person ob Faculty obj Sophie Student obj Bob Faculty obi Kathy Meg 666 Mike 111 [kslott@empress cs211spr16]$ ./a.out Printing everyone in the list Student::printInfo() Person::printInfo() 1000(ID) Meg(first_name) Ryan(last_name) 666-44-5555 (SSN) [email protected](email) MATH (major) 3.75(gpa) J(grade level) Faculty::printInfo() Person::printInfo() 1001(ID) Sophie(first_name) Watkins (last_name) 222-11-4444(SSN) [email protected](email) 110(dep_id) 15 (years) Person::printInfo() 1002(ID) Mike(first_name) Smith(last_name) 111-22-3333(SSN) [email protected](email)

Student::printInfo() Person::printInfo) 1083 (ID) Bob(first_nane) Lopez (last_name) 333-44-5555(SSN) bobecsusn.edu(email) CS(najor) 3.25(gpa) S(grade level) Faculty::printInfo() Person: printInfo() 1084 (ID) Kathy(first_nane) Ross(last_name) 222-33-4444(SSN) kathyecsusn.edu(enail) 100(dep_id) 5 years) Printing everyone in the list after sort Person::printInfo() 1002(ID) Mike(first_name) Smith(last_name) 111-22-3333(SSN) nikegcsusn.edu(etail) Faculty print Info Person::printInfo() 1001(ID) Sophie(first_name) Watkins (last_name) 222-11-4444 (SSN) sophiegcsusn.edu(email) 110(dep_id) 15 years) Faculty::printInfo() Person::printInfo() 1004(ID) Kathy(first_nane) Ross(last_name) 222-33-4444(SSN) kathyecsusn.edu(enail) 100(dep_id) 5 years) Student::printInfo() Person::printInfo() 1003(ID) Bob(first_nane) Lopez(last_name) 333-44-5555 (SSN) bobecsusn.edu(email) CS(major) 3.25(gpa) Sigrade level) Student::printInfo() Person::printInfo() 1000(ID) Meg(first_nane) Ryan(Last_name) 666-44-5555 (SSN) negocsusm.edu(email) MATH(major) 3.75 gpa) grade level) Person obi Student obj Mes Faculty obj Sophie Studentohi Bob Mike Faculty ohi Kathy
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply