-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
653 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "Circle_Task2.h" | ||
|
||
Circle::Circle(char* pSomeColor, int SomeCoord, float SomeRadius) : mRadius(SomeRadius), Shape(pSomeColor, SomeCoord) { } | ||
|
||
void Circle::Draw() { | ||
cout << "Drawing a Circle of radius " << mRadius << " ." << endl; | ||
Shape::Draw(); | ||
} | ||
|
||
float Circle::ComputeArea() { | ||
return (3.1429*mRadius*mRadius); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef CIRCLE_HEADER_Task2 | ||
#define CIRCLE_HEADER_Task2 | ||
|
||
#include "Shape_Task2.h" | ||
|
||
class Circle :public Shape{ | ||
float mRadius; | ||
public: | ||
Circle(char* = NULL, int = 0, float = 0.0); | ||
void Draw(); | ||
float ComputeArea(); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "Doctor_Task1.h" | ||
|
||
Doctor::Doctor(char* aName, int anAge, char aGender, char* aDesignation, int aSalary) :Person(aName, anAge, aGender), Designation(aDesignation), Salary(aSalary) { | ||
if (aDesignation != NULL) { | ||
int len = strlen(aDesignation) + 1; | ||
Designation = new char[len]; | ||
strcpy_s(Designation, len, aDesignation); | ||
} | ||
else { | ||
Designation = new char; | ||
strcpy_s(Designation, 1, "\0"); | ||
} | ||
} | ||
|
||
Doctor::Doctor(const Doctor& rhs) :Person(rhs) { | ||
int len = strlen(rhs.Designation) + 1; | ||
Designation = new char[len]; | ||
strcpy_s(Designation, len, rhs.Designation); | ||
} | ||
|
||
Doctor::~Doctor() { | ||
if (Designation){ | ||
delete[] Designation; | ||
} | ||
} | ||
|
||
Doctor& Doctor::operator = (const Doctor& rhs) { | ||
Person::operator = (rhs); | ||
int len = strlen(rhs.Designation) + 1; | ||
Designation = new char[len]; | ||
strcpy_s(Designation, len, rhs.Designation); | ||
return *this; | ||
} | ||
|
||
void Doctor::checkUp() { | ||
cout << getName() << " is checking up." << endl; | ||
} | ||
|
||
void Doctor::prescribe() { | ||
cout << getName() << " is giving prescribtion." << endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef Doctor_HEADER_Task1 | ||
#define Doctor_HEADER_Task1 | ||
|
||
#include"Person_Task1.h" | ||
|
||
class Doctor :public Person { | ||
char* Designation; | ||
int Salary; | ||
public: | ||
Doctor(char* = NULL, int = 0, char = '\0', char* = NULL, int = 0); | ||
Doctor(const Doctor&); | ||
~Doctor(); | ||
Doctor& operator = (const Doctor&); | ||
void checkUp(); | ||
void prescribe(); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "Line_Task2.h" | ||
|
||
Line::Line(char* pSomeColor, int SomeCoord, float SomeLength) : mLength(SomeLength), Shape(pSomeColor, SomeCoord) { } | ||
|
||
void Line::Draw() { | ||
cout << "Drawing a Line of length " << mLength << " ." << endl; | ||
Shape::Draw(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef LINE_HEADER_Task2 | ||
#define LINE_HEADER_Task2 | ||
|
||
#include "Shape_Task2.h" | ||
|
||
class Line :public Shape{ | ||
float mLength; | ||
public: | ||
Line(char* = NULL, int = 0, float = 0.0); | ||
void Draw(); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "Person_Task1.h" | ||
|
||
Person::Person(char* aName, int anAge, char aGender) :Name(aName), Age(anAge), Gender(aGender) { | ||
if (aName != NULL) { | ||
int len = strlen(aName) + 1; | ||
Name = new char[len]; | ||
strcpy_s(Name, len, aName); | ||
} | ||
else { | ||
Name = new char; | ||
strcpy_s(Name, 1, "\0"); | ||
} | ||
} | ||
|
||
Person::Person(const Person& rhs) { | ||
int len = strlen(rhs.Name) + 1; | ||
Name = new char[len]; | ||
strcpy_s(Name, len, rhs.Name); | ||
} | ||
|
||
Person::~Person() { | ||
if (Name){ | ||
delete [] Name; | ||
} | ||
} | ||
|
||
Person& Person:: operator = (const Person& rhs) { | ||
int len = strlen(rhs.Name) + 1; | ||
Name = new char[len]; | ||
strcpy_s(Name, len, rhs.Name); | ||
return *this; | ||
} | ||
|
||
void Person::eat() { | ||
cout << Name << " is eating." << endl; | ||
} | ||
|
||
void Person::walk() { | ||
cout << Name << " is walking." << endl; | ||
} | ||
|
||
const char * Person::getName()const { | ||
return Name; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef Person_HEADER_Task1 | ||
#define Person_HEADER_Task1 | ||
|
||
#include <iostream> | ||
using namespace std; | ||
|
||
class Person { | ||
char* Name; | ||
int Age; | ||
char Gender; | ||
public: | ||
Person(char* = NULL, int = 0, char = '\0'); | ||
Person(const Person&); | ||
~Person(); | ||
Person& operator = (const Person&); | ||
|
||
void eat(); | ||
void walk(); | ||
|
||
const char * getName()const; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "Person_Task3.h" | ||
|
||
Person::Person(char * aName, int anAge, char aGender) : Name(aName), Age(anAge), Gender(aGender){ | ||
if (aName != NULL) { | ||
int len = strlen(aName) + 1; | ||
Name = new char[len]; | ||
strcpy_s(Name, len, aName); | ||
} | ||
else{ | ||
Name = new char; | ||
strcpy_s(Name, 1, "\0"); | ||
} | ||
} | ||
|
||
void Person::eat(){ | ||
cout << Name << " is eating." << endl; | ||
} | ||
|
||
void Person::walk(){ | ||
cout << Name << " is walking." << endl; | ||
} | ||
|
||
const char * Person::getName()const{ | ||
return Name; | ||
} | ||
|
||
char Person::getGender()const{ | ||
return Gender; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef Person_HEADER_Task3 | ||
#define Person_HEADER_Task3 | ||
|
||
#include <iostream> | ||
using namespace std; | ||
|
||
class Person{ | ||
char * Name; | ||
int Age; | ||
char Gender; | ||
public: | ||
Person(char * = NULL, int = 0, char = '\0'); | ||
void eat(); | ||
void walk(); | ||
|
||
const char * getName()const; | ||
char getGender()const; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "PostgraduateStudent_Task3.h" | ||
|
||
PostgraduateStudent::PostgraduateStudent(char * aName, int anAge, char aGender, char * aProgram, int aStudyYear, int aProgramLength) : ProgramLength(aProgramLength), Student(aName, anAge, aGender, aProgram, aStudyYear) { } | ||
|
||
void PostgraduateStudent::teach() { | ||
cout << getName() << " is teaching." << endl; | ||
} | ||
|
||
int PostgraduateStudent::getProgramLength()const { | ||
return ProgramLength; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef PostgraduateStudent_HEADER | ||
#define PostgraduateStudent_HEADER | ||
|
||
#include "Student_Task3.h" | ||
|
||
class PostgraduateStudent :public Student { | ||
int ProgramLength; | ||
public: | ||
PostgraduateStudent(char * = NULL, int = 0, char = '\0', char * = NULL, int = 0, int = 0); | ||
void teach(); | ||
int getProgramLength()const; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "Shape_Task2.h" | ||
|
||
Shape::Shape(char* pSomeColor, int SomeCoord) : mColor(pSomeColor), mCoord(SomeCoord){ | ||
if (pSomeColor != NULL) { | ||
int Len = strlen(pSomeColor) + 1; | ||
mColor = new char[Len]; | ||
strcpy_s(mColor, Len, pSomeColor); | ||
} | ||
else { | ||
int Len = strlen("invisible") + 1; | ||
mColor = new char[Len]; | ||
strcpy_s(mColor, Len, "invisible"); | ||
} | ||
} | ||
|
||
Shape::Shape(const Shape& rhs) { | ||
int len = strlen(rhs.mColor) + 1; | ||
mColor = new char[len]; | ||
strcpy_s(mColor, len, rhs.mColor); | ||
} | ||
|
||
Shape::~Shape() { | ||
if (mColor){ | ||
delete[] mColor; | ||
} | ||
} | ||
|
||
Shape& Shape::operator = (const Shape& rhs) { | ||
int len = strlen(rhs.mColor) + 1; | ||
mColor = new char[len]; | ||
strcpy_s(mColor, len, rhs.mColor); | ||
return *this; | ||
} | ||
|
||
void Shape::Draw() { | ||
cout << "The Shape is drawn in " << mColor <<" color." << endl; | ||
} | ||
|
||
void Shape::Rotate() { | ||
cout << "Rotating a Shape of " << mColor << " color." << endl; | ||
} | ||
|
||
void Shape::SetColor(char* pSomeColor) { | ||
if (pSomeColor != NULL) { | ||
int Len = strlen(pSomeColor) + 1; | ||
mColor = new char[Len]; | ||
strcpy_s(mColor, Len, pSomeColor); | ||
} | ||
else { | ||
int Len = strlen("invisible") + 1; | ||
mColor = new char[Len]; | ||
strcpy_s(mColor, Len, "invisible"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef SHAPE_HEADER_Task2 | ||
#define SHAPE_HEADER_Task2 | ||
|
||
#include <iostream> | ||
using namespace std; | ||
|
||
class Shape{ | ||
char* mColor; | ||
int mCoord; | ||
public: | ||
Shape(char* = NULL, int = 0); | ||
Shape(const Shape&); | ||
~Shape(); | ||
Shape& operator = (const Shape&); | ||
void Draw(); | ||
void Rotate(); | ||
void SetColor(char*); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include"Student_Task1.h" | ||
Student::Student(char* aName, int anAge, char aGender, char* aProgram, int aStudyYear) :Person(aName, anAge, aGender), Program(aProgram), StudyYear(aStudyYear) { | ||
if (aProgram != NULL) { | ||
int len = strlen(aProgram) + 1; | ||
Program = new char[len]; | ||
strcpy_s(Program, len, aProgram); | ||
} | ||
else { | ||
Program = new char; | ||
strcpy_s(Program, 1, "\0"); | ||
} | ||
} | ||
|
||
Student::Student(const Student& rhs) : Person(rhs) { | ||
int len = strlen(rhs.Program) + 1; | ||
Program = new char[len]; | ||
strcpy_s(Program, len, rhs.Program); | ||
} | ||
|
||
Student::~Student() { | ||
if (Program) { | ||
delete[] Program; | ||
} | ||
} | ||
|
||
Student& Student::operator = (const Student& rhs) { | ||
Person::operator = (rhs); | ||
int len = strlen(rhs.Program) + 1; | ||
Program = new char[len]; | ||
strcpy_s(Program, len, rhs.Program); | ||
return *this; | ||
} | ||
|
||
void Student::study() { | ||
cout << getName() << " is studying." << endl; | ||
} | ||
|
||
void Student::heldExam() { | ||
cout << getName() << " is giving exam." << endl; | ||
} |
Oops, something went wrong.