Lab 11 week 11
Lab 11 week 11
Instructions:
Indent your code properly.
Use meaningful variable and function names. Use the camelCase notation.
Use meaningful prompt lines/labels for all input/output.
Strictly follow the Good Code Writing Style which is already shared by your theory
teacher.
In each file of your task either it is .cpp file or .h file Your name and roll no must be
mention in the start of your file as comment. For example, //L1F22BSCS1234 – Ali
Rehman
Students must follow the "Code Writing Guide".
You are not allowed to use string. You can use Cstring only as character arrays.
You are not allowed to use any buil-in function such as as strcopy(), strcpy_s, or.length().
Marks cannot be given on codes with run-time or compile-time errors.
Perform all the tasks in separate source, header and main driver file.
--------------------------------------------------------------------------------------------------------------------------
Task 2
In UCP, we have thousands of students who are currently enrolled in any Course. One Course has
exactly one Instructor associated with it. We need to implement this scenario to store
information of Students, Instructors, and Courses.
15. Write setter and getter for each data member of Course class.
16. Write destructor with no memory leakage.
17. Write copy constructor and assignment operator.
18. Write a display function.
19. Write a function that return total student count enrolled in class.
20. Write a display() function in Course class that displays complete Course information like
following
21. A Course cannot have more than 30 students. Write logic to implement this.
xii.) Now call name of inst1 on screen. Verify that whether inst1 is deleted
with oopLabSecC4 or not?
-----------------------------------------------------------------------------------------------------------------------------------
Task 3
In a transportation management system, the need arises to efficiently model and manage different
types of vehicles within a fleet. This scenario involves the development of classes to represent Cars,
Trucks, and Buses, each sharing common attributes like "make," "model," and "year."
Classes Structure:
Class: Vehicle
Common Attributes:
Allows access and modification of the make, model, and variant attributes.
Operators Overloaded:
Additional Attributes:
Operators Overloaded:
Additional Attributes:
• hasTrailer (bool): Indicates whether the truck is equipped with a trailer or not.
Constructor:
Operators Overloaded:
Additional Attributes:
seatingCapacity (int): Represents the maximum number of passengers the bus can
accommodate.
hasDoubleDecker (bool): Indicates whether the bus has a double-decker design or not.
Constructor:
Operators Overloaded:
Inherits and reuses the operators overloaded in the parent class.
The use of inheritance allows for code reuse, and the overridden virtual functions enable
polymorphic behaviour, allowing each derived class to provide its specific implementation of fuel
efficiency calculation.
Make sure to implement the functions and methods as per the described logic and test the classes to
ensure they function correctly. Additionally, consider adding proper error handling to enhance the
clarity and robustness of the code.