CS201 Assignment 3 Solution Fall 2021

890
CS201 Assignment no 1 fall 2021
CS201 Assignment no 1 fall 2021

CS201 Assignment 3 Solution Fall 2021

If you are searching for CS201 Assignment 3 solution for fall 2021, then you are landed on right place.

Requirement for Assignment :

Visual Studio installed in your machine. If not then download it from here.

Must have knowledge of OOP.

Handouts => Download

Past Papers Mid Term => Download

Past Papers Final Term => Download

Practice Quiz => Attempt

To Download Solution File Part 1 Attempt this Quiz.

File Part 1 is password protected. For password get it from here.

To Download Solution File Part 2 Attempt this Quiz.

File Part 2 is password protected. For password get it from here.

To Download Solution File Part 3 Attempt this Quiz.

File Part 3 is password protected. For password get it from here.

Solution for CS201 3rd Assignment Fall 2021

#include 
#include 
using namespace std;

class Employee{
private:
string empId;
string empName;
int joiningYear;
int joiningMonth;
int joiningDate;

public:
Employee(){
empId = " ";
empName = " ";
joiningYear = 0;
joiningMonth = 0;
joiningDate = 0;
}

Employee(string id, string name, int year, int month, int date){
this.setEmpId(id);
this.setEmpName(name);
this.setJoiningYear(year);
this.setJoiningMonth(month);
this.setJoiningDate(date);
}

void setEmpId(string id){
this.empId = id;
}
void setEmpName(string name){
this.empName = name;
}
void setJoiningYear(int year){
this.joiningYear = year;
}
void setJoiningMonth(int month){
this.joiningMonth = month;
}
void setJoiningDate(int date){
this.joiningDate = date;
}

string getEmpId(){
return this.empId;
}
string getEmpName(){
return this.empName;
}
int getJoiningYear(){
return this.joiningYear;
}
int getJoiningMonth(){
return this.joiningMonth;
}
int getJoiningDate(){
return this.joiningDate;
}

void setValues(Employee emp){
this.empId = emp2->empId;
this.empName = emp2->empName;
this.joiningYear = emp2->joiningYear;
this.joiningMonth = emp2->joiningMonth;
this.joiningDate = emp2->joiningDate;
}

void display(Employee emp){
cout<<"ID : "<<emp.getEmpId()<<endl;
cout<<"Name : "<<emp.getEmpName()<<endl;
cout<<"Joining Year : "<<emp.getJoiningYear()<<endl;
cout<<"Joining Month : "<<emp.getJoiningMonth()<<endl;
cout<<"Joining Date : "<<emp.getJoiningDate()<<endl<<endl;
}
};

int main(){

Employee emp1;
Employee emp2("BC123456789","Muhammad",2017,3,16);

cout<<"Employee 1 using default constructor : "<<endl;
emp1.display(emp1);

cout<<"Employee 2 using parameterized constructor : "<<endl;
emp2.display(emp2);

emp1.setValues(&emp2);
cout<<"Employee 1 having Employee 2 copied data memebers values : "<<endl;
emp1.display(emp1);

return 0;
}

 

Note before coping solution:

This is only just an idea solution you must have to include your own logic into this for 100% marks. You can take it just like a framework for CS201 Assignment Solution.