Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
saif86 authored Nov 26, 2018
1 parent 8e6d7ec commit bac8168
Show file tree
Hide file tree
Showing 29 changed files with 653 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Circle_Task2.cpp
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);
}
14 changes: 14 additions & 0 deletions Circle_Task2.h
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
41 changes: 41 additions & 0 deletions Doctor_Task1.cpp
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;
}
18 changes: 18 additions & 0 deletions Doctor_Task1.h
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
8 changes: 8 additions & 0 deletions Line_Task2.cpp
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();
}
13 changes: 13 additions & 0 deletions Line_Task2.h
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
44 changes: 44 additions & 0 deletions Person_Task1.cpp
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;
}
23 changes: 23 additions & 0 deletions Person_Task1.h
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
29 changes: 29 additions & 0 deletions Person_Task3.cpp
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;
}
20 changes: 20 additions & 0 deletions Person_Task3.h
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
11 changes: 11 additions & 0 deletions PostgraduateStudent_Task3.cpp
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;
}
14 changes: 14 additions & 0 deletions PostgraduateStudent_Task3.h
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
54 changes: 54 additions & 0 deletions Shape_Task2.cpp
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");
}
}
20 changes: 20 additions & 0 deletions Shape_Task2.h
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
40 changes: 40 additions & 0 deletions Student_Task1.cpp
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;
}
Loading

0 comments on commit bac8168

Please sign in to comment.