Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
48af704
1: homework 01 - library management system
samxalpolad66 Sep 9, 2026
5fc6340
Update homework-01-library-management-system.cpp
samxalpolad66 Sep 9, 2026
a6faf0f
Update homework-02-employee-management-system.cpp
samxalpolad66 Sep 9, 2026
0268d9c
Update homework-03-bank-account-encapsulation.cpp
samxalpolad66 Sep 9, 2026
db44394
Update homework-04-employee-setters-and-getters.cpp
samxalpolad66 Sep 9, 2026
ea0b99f
Update homework-05-online-shop-system.cpp
samxalpolad66 Sep 9, 2026
bc0cd8b
Update homework-06-library-oop-principles.cpp
samxalpolad66 Sep 9, 2026
5454317
Update homework-07-bank-account-basics.cpp
samxalpolad66 Sep 9, 2026
3d3b97c
Update homework-08-bank-and-account-classes.cpp
samxalpolad66 Sep 9, 2026
f531162
Update homework-09-math-chaining-with-pointers.cpp
samxalpolad66 Sep 9, 2026
69c5c53
Update homework-10-math-chaining-with-references.cpp
samxalpolad66 Sep 9, 2026
a138bc8
Update homework-11-student-classroom-struct.cpp
samxalpolad66 Sep 9, 2026
c8791d1
Update homework-12-linked-list.cpp
samxalpolad66 Sep 9, 2026
f0ba623
Update homework-13-stack.cpp
samxalpolad66 Sep 9, 2026
0ee8a81
Update homework-14-queue.cpp
samxalpolad66 Sep 9, 2026
cd1ce9f
Update homework-01-protected-members.cpp
samxalpolad66 Sep 9, 2026
bf7894c
Update homework-02-library-management-system.cpp
samxalpolad66 Sep 9, 2026
6d770a5
Update homework-03-multiple-inheritance.cpp
samxalpolad66 Sep 9, 2026
c5b8009
Update homework-04-inheritance-access-types.cpp
samxalpolad66 Sep 9, 2026
9d1f5f3
Update homework-05-banking-inheritance-types.cpp
samxalpolad66 Sep 9, 2026
68f6171
Update homework-06-custom-constructors-with-inheritance.cpp
samxalpolad66 Sep 9, 2026
c62cc45
Update homework-01-shape-hierarchy.cpp
samxalpolad66 Sep 9, 2026
cd25998
Update homework-02-library-item-hierarchy.cpp
samxalpolad66 Sep 9, 2026
bed91b2
Update homework-03-polymorphic-methods-theory-question.cpp
samxalpolad66 Sep 9, 2026
f9925d0
Update homework-04-payment-virtual-methods.cpp
samxalpolad66 Sep 9, 2026
aa29709
Update homework-05-employee-polymorphism.cpp
samxalpolad66 Sep 9, 2026
2d3b73d
Update homework-06-backend-service-hierarchy.cpp
samxalpolad66 Sep 9, 2026
a5517b3
Update homework-07-banking-system.cpp
samxalpolad66 Sep 9, 2026
4fad486
Update homework-08-static-keyword-stock-tracker.cpp
samxalpolad66 Sep 9, 2026
b839d38
Update homework-09-static-members-late-fees.cpp
samxalpolad66 Sep 9, 2026
a2e876c
Update homework-10-static-members-shape-areas.cpp
samxalpolad66 Sep 9, 2026
24191ac
Update homework-11-user-hierarchy-levels.cpp
samxalpolad66 Sep 9, 2026
aea0066
Update homework-12-final-keyword-authenticator.cpp
samxalpolad66 Sep 9, 2026
d959226
Update homework-13-final-keyword-database-connection-factory.cpp
samxalpolad66 Sep 9, 2026
2c5ae9b
Update homework-14-abstract-data-storage-provider.cpp
samxalpolad66 Sep 9, 2026
e1148ad
Update homework-15-abstract-payment-provider.cpp
samxalpolad66 Sep 9, 2026
f9cb68f
Update homework-16-backend-storage-interface.cpp
samxalpolad66 Sep 9, 2026
ca63910
Update homework-17-abstract-shape-interface.cpp
samxalpolad66 Sep 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,44 +1,51 @@
#include <iostream>
#include <string>

using namespace std;

/*
Exercise: Library Management System

Description:
Design and implement a Library Management System using classes and access specifiers in C++.
The system should allow you to manage books in a library.

Requirements:

1. Create a class named "Book" with the following attributes:
1. Create a class named "Book" with the following attributes:
Title (a string)
Author (a string)
Publication Year (an integer)
ISBN (a string)

2. Make the attributes private to encapsulate them.

3. Include member functions to:
Set the book details (title, author, publication year, ISBN).
Display the book details.

4. Create objects of the "Book" class and demonstrate accessing and modifying the attributes using member functions.

Tips:
Use access specifiers (public and private) to control access to class members.
You can choose to implement the member functions directly in the class declaration (inline) or define them outside the class.
Test the functionality of the class by creating book objects, setting their details, and displaying the information.
This exercise will help you practice using access specifiers to control the visibility of class members and understand the concept of encapsulation.
*/



/* Solution */



class Book{
private:
string Title;
string Author;
int PublicYear;
string ISBN;
public:
void setBookDetails(string bookname ,string author , int year , string isbn){
Title = bookname;
Author = author;
PublicYear = year;
ISBN = isbn;
}
void displayBookDetails(){
cout << Title <<endl;
cout << Author << endl;
cout << PublicYear << endl;
cout << ISBN << endl;
}

};
int main() {

/* Example usage: */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,36 @@
#include <iostream>
#include <string>

using namespace std;

/*
Exercise: Employee Management System

Description:
Design and implement an Employee Management System using classes and constructors in C++.
The system should allow you to create and manage employee records.

Requirements:

1. Create a class named "Employee" with the following attributes:
Employee ID (an integer)
Employee name (a string)
Employee designation (a string)
Employee salary (a floating-point number)

2. Implement the following constructors for the "Employee" class:
A parameterized constructor that initializes all the attributes based on provided values.
A default constructor that sets default values for the attributes.

3. Include member functions to:
Set and get the employee attributes (ID, name, designation, salary).
Display the employee details.

4. Create multiple employee objects using different constructors and display their details.

Tips:
Use appropriate access specifiers (such as private and public) for the class members.
Consider using default values in the parameterized constructor to provide flexibility when creating objects.
Test the functionality of constructors by creating objects with and without providing initial values.
This exercise will help you practice creating and initializing objects using constructors and defaulted constructors, as well as accessing and displaying object attributes.
*/



/* Solution */



int main() {

/* Example usage: */

// Creating employee objects using different constructors
class Employee{
private:
int ID;
string name;
string designation;
double salary;
public:
Employee(int pID = 0 , string Pname = "Unknown" , string Pdesignation = "unknown" , double Psalary = 0.0){
ID = pID;
name = Pname;
designation = Pdesignation;
salary = Psalary;
}

void setID(int pID){ID = pID;}
void setName(string Pname){name = Pname;}
void setDesignation(string Pdesignation){designation = Pdesignation;}
void setSalary(double Psalary){salary = Psalary;}

void displayDetails(){
cout << ID << endl;
cout << name << endl;
cout << designation << endl;
cout << salary << endl;

}

};
int main(){
system("cls");
Employee emp1(101, "John Doe", "Manager", 5000.0);
Employee emp2;

Expand All @@ -64,4 +49,4 @@ int main() {
cout << endl;

return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ class BankAccount {
// Constructor
BankAccount(int accountNumber, const string &holderName, double initialBalance) {
// TODO: Initialize member variables
this -> accountNumber = accountNumber;
this -> holderName = holderName;
balance = initialBalance;
}
void deposit(double amount){
balance = balance + amount;
}
void withdraw(double amount){
if(amount < balance){
balance = balance - amount;
}
else{
cout << "Invalid" << endl;
}
}
double CheckBalance(){
return balance;
}

// Member functions
Expand All @@ -38,6 +55,7 @@ class BankAccount {


int main() {
system("cls");

// TODO: Create an instance of the BankAccount class
// TODO: Test the deposit, withdraw, and check balance operations
Expand All @@ -55,7 +73,15 @@ int main() {
This exercise will help you practice encapsulation and understand how to hide
implementation details while exposing a controlled interface to the users of your class!
*/
BankAccount acc1(12, "Shamkhal", 890.8);
BankAccount acc2(15, "Ali", 500.0);

acc1.deposit(32.1);
acc1.withdraw(44.3);
cout << "Shamkhal balance: " << acc1.CheckBalance() << endl;

return 0;
acc2.deposit(100.0);
acc2.withdraw(50.0);
cout << "Ali balance: " << acc2.CheckBalance() << endl;
}

Original file line number Diff line number Diff line change
@@ -1,57 +1,46 @@
#include <iostream>
#include <string>

using namespace std;

/*
Exercise: Employee Management System

You are tasked with creating an employee management system for a company.
Each employee has a name, age, position, and salary.
Your goal is to implement a class called Employee that encapsulates
these attributes and provides appropriate setters and getters.

Your task is to create a C++ class called Employee with the following specifications:

1. Private member variables:
name (string): Holds the name of the employee.
age (int): Holds the age of the employee.
position (string): Holds the position/title of the employee.
salary (double): Holds the salary of the employee.

2. Public member functions:
setName(const string& name): Sets the name of the employee.
setAge(int age): Sets the age of the employee.
setPosition(const string& position): Sets the position of the employee.
setSalary(double salary): Sets the salary of the employee.
getName() const: Returns the name of the employee.
getAge() const: Returns the age of the employee.
getPosition() const: Returns the position of the employee.
getSalary() const: Returns the salary of the employee.

Your implementation should allow external code to set and get the attributes of
an Employee object using the appropriate setter and getter functions.

Here's a code template to get you started:
*/

class Employee {
class Employee{
private:
string name;
int age;
string position;
double salary;

public:
// TODO: Implement setters and getters

void setName(const string& name){this -> name = name;}
void setAge(int age){this -> age = age;}
void setPosition(const string& position){this -> position = position;}
void setSalary(double salary){this -> salary = salary;}

string getName()const{return name;}
int getAge()const{return age;}
string getPosition() const{return position;}
double getSalary() const{return salary;}
};
int main(){
system("cls");
Employee employee;
employee.setName("Shamkhal");
employee.setAge(18);
employee.setPosition("data scientist");
employee.setSalary(0);
cout << "about of employee" << endl;
cout << employee.getName() << endl;
cout << employee.getAge() << endl;
cout << employee.getPosition() <<endl;
cout << employee.getSalary() << endl;
cout << "about of employee 2" << endl;
Employee employee2;
employee2.setName("Ali");
employee2.setAge(134);
employee2.setPosition("Angel");
employee2.setSalary(0);
cout << employee2.getName() << endl;
cout << employee2.getAge() << endl;
cout << employee2.getPosition() <<endl;
cout << employee2.getSalary() << endl;


int main() {

// TODO: Test the Employee class by creating an object, setting attributes, and getting attribute values

return 0;
}

Loading