0% found this document useful (0 votes)
2 views

Assignment 1 (1)

This document outlines Assignment #1 for the Object Oriented Programming course (CS-212) at the Department of Computer Science, due on March 4, 2025. Students are required to create classes for four unique real-world entities in C++, each with three data members and three member functions, along with explanations for their choices. Submission guidelines include formatting requirements and a strict policy against plagiarism.

Uploaded by

uzairkakar388
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Assignment 1 (1)

This document outlines Assignment #1 for the Object Oriented Programming course (CS-212) at the Department of Computer Science, due on March 4, 2025. Students are required to create classes for four unique real-world entities in C++, each with three data members and three member functions, along with explanations for their choices. Submission guidelines include formatting requirements and a strict policy against plagiarism.

Uploaded by

uzairkakar388
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Department of Computer Science

Object Oriented Programming

CS-212

Assignment # 1
Due Date: Tuesday, 04 March 2025

Student Details:
Name:
NUST ID:
Semester: Spring 2025 Batch: BSAI

Obtained Marks:
Total Marks: 20

Important Instruction
Fill your information on the cover page.
Make your work clear and well-presented.
Copying from other students or resources will result in ZERO mark.
Number all the subsequent pages properly.

1
Department of Computer Science

Assignment:
Find 04 real-world entities and create a class for each entity using proper C++ syntax. Each
entity carries equal marks (05 marks each).
Each class must have at least:
 03 Data Members (Attributes)
 03 Member Functions (Methods)
 Write a one-line description for each data member and member function explaining
why you have chosen it for this class.
 Each student must choose unique entities (no two students should have the same
classes).
 Plagiarism or copying from others will result in a zero score.

Submission Guidelines:
 Submit your assignment as a .docx file.
 Ensure your code is well-formatted and properly indented.
 Add comments explaining your logic.
 Any copied work will be marked as zero.
 Assignment file name should be like this. studentName.docx i.e., muhammadAli.docx.

2
Department of Computer Science

Sample Example: Answer


Entity-1: MobilePhone
Class Name: MobilePhone
Data Members (Attributes):
1. string brand; // Represents the brand of the phone (e.g., Samsung, Apple).
2. double price; // Stores the price of the phone.
3. int batteryLife; // Stores battery life in hours.
Member Functions (Methods):
1. void makeCall(string number); // Simulates making a phone call to a given number.
2. void sendMessage(string message); // Allows sending a text message.
3. void showDetails(); // Displays the phone’s brand, price, and battery life.

C++ Code Example:


#include <iostream>
using namespace std;
class MobilePhone {
public:
string brand; // Represents the brand of the mobile phone

double price; // Stores the price of the phone


int batteryLife; // Battery life in hours
// This function is used for making call
void makeCall(string number) {
cout << "Calling " << number << "..." << endl;
}
// This function is used for Sending Message

void sendMessage(string message) {


cout << "Sending Message: " << message << endl;

3
Department of Computer Science
}
// This function is used for showing details of mobile

void showDetails() {
cout << "Brand: " << brand << ", Price: $" << price << ",
Battery Life: " << batteryLife << " hours" << endl;
}
};
// Main Function

int main() {
MobilePhone myPhone;
// Assigning values

myPhone.brand = "Samsung";
myPhone.price = 799.99;
myPhone.batteryLife = 24;
// Using Member Functions

myPhone.showDetails();
myPhone.makeCall("123-456-7890");
myPhone.sendMessage("Hello, how are you?");
return 0;
}
Output

You might also like