This is exercise builds on the previous Exercise (Inheritance 2) classes. In this series of exercises we'll take the StudentType class and expand it to also hold a list of courses that the student has taken. Starting out we want to build a CourseType class that will hold the basic course information

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

This is exercise builds on the previous Exercise (Inheritance 2) classes. In this series of exercises we'll take the StudentType class and expand it to also hold a list of courses that the student has taken.

Starting out we want to build a CourseType class that will hold the basic course information:

  • Create a CourseType class. (Keep it simple at this point. You don't need to put in "extra" members just to make it a bigger class.)
  • You should create this class with its own .cpp and .h file, but include it in a "project" with your already existing StudentType class. (You can use your own StudentType solution or the one provided from the previous exercise.) Note: At this point you shouldn't be changing anything in the existing StudentType files!
  • Make sure you test your new CourseType class by declaring an object and testing at least it's constructor.

Submit: Commented test, implementation and header files (.cpp and .h) for new CourseType along with previous StudentType and PersonType zipped into a single 

I have submitted a picture of my personType.h file and personType.cpp implementation file as context. I just need a very, very simple courseType class .h and .cpp file

These are the studentType header and Implementation files I have:

//studentType.h

#ifndef STUDENTTYPE_H_INCLUDED
#define STUDENTTYPE_H_INCLUDED

#include "personType.h"
#include <iostream>
#include <string>

//base class = personType , derived class = studentType
class studentType : public personType {

public:
//constructor
studentType();

//first name and last name
studentType (string, string);
//first name, last name, student ID, major declaration, GPA
studentType (string, string, int, string, double);

//acquire GPA
void setGPA (double);
//acquire unique numerical student ID
void setID (int);
//assigns Major declaration based on student's curriculum
void setMajor (string);
//overrides parents' print function
void print() const;

//get's GPA based on calculated GPA
double getGPA() const;
//get function that acquires student's unique ID
int getID() const;
//get function that acquire's student major declaration
string getMajor() const;

private:
//variable for student's unique ID
int id;
//variable that stores GPA
double gpa;
//variable that stores major declaration
string major;


};
#endif // STUDENTTYPE_H_INCLUDED

//studentTypeImp.cpp

#include "studentType.h"
#include <iostream>
#include <string>
using namespace std;

studentType::studentType() : personType ("","") {
id = 0;
major = "";
gpa = 0;
}
studentType::studentType (string first, string last) : personType() {
id = 0;
major = "";
gpa = 0;
}
studentType::studentType (string first, string last, int id, string major,
double gpa) : personType (first, last) {
this -> id = id;
this -> major = major;
this -> gpa = gpa;
}
void studentType::setGPA (double gpa) {
this -> gpa = gpa;
}
void studentType::setID (int id) {
this -> id = id;
}
void studentType::setMajor (string major) {
this -> major = major;
}
void studentType::print() const {
personType::print();
cout << " ID: " << id;
cout << " Major: " << major;
cout << " GPA: " << gpa;
}

double studentType::getGPA() const {
return gpa;
}
int studentType::getID() const {
return id;
}
string studentType::getMajor() const {
return major;
}

1
//personTypeImp.R
2
#include <iostream>
4
#include <string>
5 #include "personType.h"
6.
using namespace std;
7
Evoid personType::print () const {
8
cout << firstName << "" << lastName;
10
11
Evoid personType::setName (string first, string last)
12
firstName = first;
13
lastName = last;
14
15
string personType::getFirstName () const
16
17
return firstName;
18
Estring personType::getLastName () const {
19
20
return lastName;
21
22
//constructor
OpersonType::personType (string first, string last) {
firstName - first;
23
24
25
lastName = last;
26
Transcribed Image Text:1 //personTypeImp.R 2 #include <iostream> 4 #include <string> 5 #include "personType.h" 6. using namespace std; 7 Evoid personType::print () const { 8 cout << firstName << "" << lastName; 10 11 Evoid personType::setName (string first, string last) 12 firstName = first; 13 lastName = last; 14 15 string personType::getFirstName () const 16 17 return firstName; 18 Estring personType::getLastName () const { 19 20 return lastName; 21 22 //constructor OpersonType::personType (string first, string last) { firstName - first; 23 24 25 lastName = last; 26
1
V/personType.h
2
3
#include <string>
4
5
using namespace std;
6
7
class personType
8
日
9
public:
10
void print () const;
11
//Function to output the first name and last name
12
//in the form firstName lastName.
13
void setName (string first, string last);
//Function to set firstName and lastName according
14
15
16
//to the parameters.
17
//Postcondition: firstName = first; lastName = last
18
19
string getFirstName () const;
20
//Function to return the first name.
21
//Postcondition: The value of firstName is returned.
22
23
string getLastName () const;
//Function to return the last name.
25
//Postcondition: The value of lastName is returned.
26
27
personType (string first =
string last = "");
28
//Constructor
//Sets firstName and lastName according to the parameters.
//The default values of the parameters are null strings.
29
30
//Postcondition: firstName = first; lastName = last
33
private:
34
string firstName; //variable to store the first name
35
string lastName;
//variable to store the last name
36
N22 N2
333 3
Transcribed Image Text:1 V/personType.h 2 3 #include <string> 4 5 using namespace std; 6 7 class personType 8 日 9 public: 10 void print () const; 11 //Function to output the first name and last name 12 //in the form firstName lastName. 13 void setName (string first, string last); //Function to set firstName and lastName according 14 15 16 //to the parameters. 17 //Postcondition: firstName = first; lastName = last 18 19 string getFirstName () const; 20 //Function to return the first name. 21 //Postcondition: The value of firstName is returned. 22 23 string getLastName () const; //Function to return the last name. 25 //Postcondition: The value of lastName is returned. 26 27 personType (string first = string last = ""); 28 //Constructor //Sets firstName and lastName according to the parameters. //The default values of the parameters are null strings. 29 30 //Postcondition: firstName = first; lastName = last 33 private: 34 string firstName; //variable to store the first name 35 string lastName; //variable to store the last name 36 N22 N2 333 3
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education