0% found this document useful (0 votes)
52 views6 pages

Assignment 7

Uploaded by

seif798mostafa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views6 pages

Assignment 7

Uploaded by

seif798mostafa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

//Assigment 7

//-Q1-
//#include <iostream>
//using namespace std;
//class Circle {
//protected:
// double raduis;
// string color;
//public:
// Circle() {
// raduis = 1.0;
// color = "red";
// }
// Circle(double r) {
// raduis = r;
// }
// Circle(double r , string c) {
// raduis = r;
// color = c;
// }
// void setRaduis(double r) {
// raduis = r;
// }
// double getRaduis() {
// return raduis;
// }
// void setColor(string c) {
// color = c;
// }
// string getColor() {
// return color;
// }
// double getArea() {
// return (22.0 / 7) * raduis * raduis;
// }
// void display_info() {
// cout << "Area: " << getArea()<<endl;
// cout << "Radius: " << raduis<<endl;
// cout << "Color: " << color << endl;
// }
//};
//class Cylinder : public Circle {
// double height;
//public:
// Cylinder() {
// height = 1.0;
// }
// Cylinder(double r) {
// raduis = r;
// }
// Cylinder(double r, double h) : Circle(r) {
// height = h;
// }
// Cylinder(double r , double h , string c) : Circle(r,c) {
// height = h;
// }
// double getHeight() {
// return height;
// }
// void setHeight(double h) {
// height = h;
// }
// double getVolume() {
// return getArea() * height;
// }
//};
//int main() {
// Cylinder C1(2,3,"black");
// C1.display_info();
// cout << "volume: " << C1.getVolume();
//}
//========================================
//-Q2-
//#include <iostream>
//using namespace std;
//class Customer {
// int Id;
// string Name;
// int Discount;
//public:
// Customer() {
// Id = 0;
// Discount = 0;
// }
// Customer(int id , string n, int dis) {
// Id = id;
// Name = n;
// Discount = dis;
// }
// int getId() {
// return Id;
// }
// string getName() {
// return Name;
// }
// int getDiscount() {
// return Discount;
// }
// void setDiscount(int dis) {
// Discount = dis;
// }
// void display_info() {
// cout << "Id: " << Id << endl;
// cout << "Name: " << Name << endl;
// cout << "Discount: " << Discount << endl;
// }
//};
//class Invoice {
// int Id;
// Customer customer;
// double Amount;
//public:
// Invoice(int id, Customer cust, double amount) {
// Id = id;
// Amount = amount;
// customer = cust;
// }
// int getId() {
// return Id;
// }
// Customer getCustomer() {
// return customer;
// }
// void setCustomer(Customer cust) {
// customer = cust;
// }
// double getAmount() {
// return Amount;
// }
// void setAmount(double amount) {
// Amount = amount;
// }
// int getCustomerId() {
// return customer.getId();
// }
// string getCustomerName() {
// return customer.getName();
// }
// int getCustomerDiscount() {
// return customer.getDiscount();
// }
// double getAmountAfterDiscount() {
// Amount = Amount - ((Amount * customer.getDiscount()) / 100);
// return Amount;
// }
// void display_info() {
// customer.display_info();
// cout<<"Id Invoice: "<<Id<<endl;
// cout << "Amount: " << Amount << endl;
// cout << "Amount after discount: "<< getAmountAfterDiscount() << endl;
// }
//};
//int main() {
// Customer c(11,"seif",10);
// Invoice I1(22,c,1000);
// I1.display_info();
//}
//=============================================
// -Q3-
//#include <iostream>
//using namespace std;
//class Person {
//protected:
// string firstName;
// string lastName;
//public:
// Person() {
//
// }
// Person(string first , string last) {
// firstName = first;
// lastName = last;
// }
// void display_info() {
// cout << "First Name: " << firstName << endl;
// cout << "Last Name: " << lastName << endl;
// }
// void setName(string first , string last) {
// firstName = first;
// lastName = last;
// }
// string getFirstName() {
// return firstName;
// }
// string getLastName() {
// return lastName;
// }
//};
//class Doctor : public Person {
// string specialiity;
//public:
// Doctor() {
//
// }
// Doctor(string fn , string ln , string sp) : Person(fn,ln) {
// specialiity = sp;
// }
// void setSpeciality(string sp) {
// specialiity = sp;
// }
// string getSpeciality() {
// return specialiity;
// }
//};
//class Date {
// int Month;
// int Day;
// int Year;
//public:
// Date() {
// Month = 0;
// Year = 0;
// Day = 0;
// }
// Date(int Y, int M, int D) {
// Year = Y;
// Month = M;
// Day = D;
// }
// void setDate(int Y, int M, int D) {
// Year = Y;
// Month = M;
// Day = D;
// }
// int getMonth() {
// return Month;
// }
// int getDay() {
// return Day;
// }
// int getYear() {
// return Year;
// }
//};
//class Patient {
// int patientld;
// int Age;
// Date Dob;
// Date AdmitDate;
// Date DischargeDate;
// Doctor physician;
// Patient(int pat, int ag, Date dob, Date admitDate, Date dischargeDate, Doctor
phy) {
// patientld = pat;
// Age = ag;
// Dob = dob;
// AdmitDate = admitDate;
// DischargeDate = dischargeDate;
// physician = phy;
// }
// Date getAdmitDate() {
// return AdmitDate;
// }
// void setDischargeDate(Date disch) {
// DischargeDate = disch;
// }
// Date getDischargeDate() {
// return DischargeDate;
// }
// void setPhysician(Doctor phy) {
// physician = phy;
// }
// Doctor getPhysician() {
// return physician;
// }
//};
//int main() {
//
//}
//=====================================
//-Q4-
‫(؟‬inheritance)‫(و‬composition)‫الفرق بين‬
(composition) : ‫ متغير الداتا‬1‫اقدر احط اوبجيكت جوه كالس بمعني اني اقدر احط جوه كالس‬
2 ‫تايب بتاعته كالس‬
2 ‫ جواه اوبجيكت من كالس‬1‫وبكدا يبقي كالس‬
exampel 1 : (Customer)‫هنعمل كالس اسمه‬
:‫المتغيرات ال فيه‬
1-string name
2-int Id
3-int Discount
(Invoice)‫هنعمل كالس تاني اسمه‬
:‫المتغيرات الي فيه‬
1-Customer cust1
2-int Id
3-double amount

(inheritance) : ‫بنسخدمه لما بيكون فيه اتنين كالس وانا عايز يبقي فيه كالس فيهم يقدر‬
‫يستخدم كل المتغيرات و الفانكشنز الموجوده في التاني‬
exampel 2 :(parent)(person)‫هنعمل كالس اسمه‬
:‫المتغيرات ال فيه‬
1-string name
2-int Id
(chiled)(Doctor)‫هنعمل كالس تاني اسمه‬
:‫المتغيرات الي فيه‬
1-int NumberOfPatients
2-int Salary

You might also like