Object Oriented Programming
Session: Fall 2024
Assignment no ONE:
Due Handwritten on Wed Oct 30, 2024 in Class
AND Portal Submission at 23:59 PM Wed Oct 30, 2024
No Use of ChatGPT Please (Zero Marks)
100 Marks
Final Marks are based on Assignment Evaluation
PF concepts and writing class-based code from function-based code
Topic
Objective/ • Transform Function-based code to class-based Code
Outcome • Writing code of simple classes
# of One
Problems
Portal Submission Instructions
• Each Problem must be in a Single CPP file that should compile and run
• NO ZIP OR RAR FILES (ZERO MARKS)
• The CPP file name must be as per the following convention:
o F24_OOP_Section_Registration_A1.cpp (25 % marks deduction if this is not followed)
o For example .CPP file for Section C15 and registration L1S24BSCS001 MUST have this
name:
F24_OOP_C15_ L1S24BSCS001_A1.cpp
• In CPP file: (25 % marks deduction if not followed)
o The first lines in comments must contain: your name, registration, assignment number
o AND copy the problem statement
Here is a template CPP file for problem one
/*
Ahmad Usman L1F23BSCS0012
Fall 2024 OOP Section C15 Assignment One
8 Parties Participated in the election and their votes are recorded in a text file “[Link]” (see sample
text file below as an example only. This file may contain any values). You will need to read the votes
from the file and write the type of output (see below for the example “[Link]” file that
correspond to the “[Link]” file).
Example text File “[Link]”
• first number is total number of votes
• Each Entry is ID of one of the Parties e.g. 1 is for PPP, 2 is for PML-N and so on
For vote count, just count the number of times a party ID is present in the file e.g. for PPP (ID 1) is
present 7 times hence the votes of PP are 7
*/
#include <iostream>
#include <fstream>
using namespace std;
// 1. Class Declaration
// 2. Global Function Prototypes
// 3. Main function
int main()
{
// write code here
return 0;
}
4. // Class Definition
5. // Global Function Definition
Marking Scheme:
• Handwritten part is 50 marks
• Portal Submission is 50 Marks
• Each Day Assignment is Late is 25 % marks deduction per day
• 100 Marks of Assignment One are divided as Following:
o Part One in English: 40 marks:
▪ Analysis (20 Marks)
▪ Class Structure (10 marks)
▪ Global Functions (10 Marks)
o Part Two in C++: 60 Marks
▪ Class Declaration (10 Marks)
▪ Global Function Prototypes (10 Marks)
▪ Class Definition (30 Marks)
▪ Global Functions Code (10 Marks)
• Division of marks for Above Code Parts
o Correct Code: 20 % marks
o Correct Syntax: 20 % Marks
o Correct Output Matching the Format of the Sample Output: 30 % marks
• Marks Deductions:
o Not Following Instructions (up to 100 % marks deductions)
o Not Following Good Code Writing Practices as Listed below (2 marks per violation)
▪ Meaningful and Correct names of Class (proper noun with first letter Capital),
variables (proper noun with first letter lowercase) and functions (verbs with first
letter lowercase)
▪ Each variable in a separate line
▪ Each variable must be initialized
▪ Use of Indentation and White spaces to make code readable
Each if, else, while, for, do-while etc. must have brackets { }
• Handwritten on Time Submission 50 Marks
o Code is not the same as that of portal submission: zero marks
• Use of ChatGPT is Zero Marks
• Use of Advance C++ than Covered in Class is zero Marks
• Copy is Zero for All Parties
• Portal on Time Submission 50 Marks
o Code does not compile or run: zero marks
o Code is not the same as that of handwritten: zero marks
Problem:
You have written the Function-Based Code in Assignment Zero, now it this problem you will transform
the function-based code into class-based code using the required steps.
Statement
8 Parties Participated in the election and their votes are recorded in a text file “[Link]” (see sample
text file below as an example only. This file may contain any values). You will need to read the votes
from the file and write the type of output (see below for the example “[Link]” file that correspond
to the “[Link]” file).
Example text File “[Link]”
• first number is total number of votes
• Each Entry is ID of one of the Parties e.g. 1 is for PPP, 2 is for PML-N and so on
For vote count, just count the number of times a party ID is present in the file e.g. for PPP (ID 1)
is present 7 times hence the votes of PP are 7
45 1 2 3 1 2 3 4 5 7 1 2 3 4 8 7 6 1 2 3 4 5 6 7 8 8 7 6 5 1 2 3 4 5 7 7 7 7 7 8 8 8 1 1 4 6
Example Output Text File “[Link]”
Party Name Party ID Votes
---------------- ----------- --------
PPP 1 7
PML-N 2 5
PTI 3 5
ANP 4 5
JIP 5 4
JUI 6 4
MQM 7 9
PAT 8 6
MQM *********
PPP *******
PAT ******
PML-N *****
PTI *****
ANP *****
JIP ****
JUI ****
This assignment must be done in 2 parts, part one is analysis, thinking and
planning without C++ code and part two is C++ code that implement Part One
in a Class-Based Code from the Function-Based code of Assignment Zero.
PART ONE (Analysis, thinking and Solution Plan)
(In this part you will do the following without any coding:
1. Analysis (You may copy this part from Assignment zero, after revision)
a. What is given? Clearly state what information/data is given
b. What is required? Clearly state what is required for you to do and what will be the
outcome?
2. Class Structure in English Only:
a. Decide an Appropriate Class Name (Proper Noun)
b. Decide Class Private Variables and Data Types
c. Decide Class Functions, Input and Output Parameters
3. Global Functions in English Only:
a. Names of Functions
b. Input and Output Parameters of Functions
PART TWO (C++ Code of PART ONE in a Class)
Here you will write C++ code, FOLLOWING STEPS:
1. Write Class Declaration (Prototype)
2. Write Global Function Declaration (Prototype)
3. Write Code of function main
4. Write Class Definition (Code of Class Functions)
5. Write Global Functions Definition (Code of Global Functions)
Constraints
• Main function must not have any cin, cout or math
• Use maximum number of Functions, each function must have at least 5 lines of code, , obeying
the principal: One Function – One Task
• Use only Dynamic Arrays, although you may use local static (fixed size) arrays in functions.
• All functions must have return type void