Practice Programming II
Practice Programming II
Question 2 :Design a class named Manager in C++ with the following specifications:
Question :Design a class template named Matrix in C++ with the following specifications:
• The class should have a private data member matrix for the matrix.
• A constructor that initializes the matrix, and a destructor that deletes the matrix.
• Get and set methods for the matrix, and a method getSize that returns the size of the
matrix.
• Overload the () operator to access elements of the matrix. The function should throw
an exception if the index is out-of-bounds. Write a program that demonstrates the
functionality of the Matrix class by doing the following:
• Create a few Matrix objects and print their details.
• Access and modify elements of the matrices using the overloaded () operator.
Question :Design a class named Aircraft in C++ with the following specifications:
• The class should have the following private data members: manufacturer (a string),
model (a string), and year (an integer).
• A pure virtual function named printDetails.
• A destructor that prints a message saying the aircraft is being deleted. Then, design
two classes named Helicopter and Airplane that inherit from the Aircraft class. These
classes should override the printDetails function. Next, design a class named
FlyingCar that inherits from both the Helicopter and Airplane classes (demonstrating
multiple inheritance). This class should also override the printDetails function.
Finally, design a class named VirtualHelicopter that virtually inherits from the
Helicopter class (demonstrating virtual inheritance). This class should also override
the printDetails function. Write a program that demonstrates the functionality of the
Aircraft, Helicopter, Airplane, FlyingCar, and VirtualHelicopter classes by doing the
following:
• Create a few Helicopter, Airplane, FlyingCar, and VirtualHelicopter objects and print
their details.
Question 5 :Design a class named University in C++. The class should have the following
specifications:
Question 6 :Design a class named Director in C++ with the following specifications:
Question 7 :Design a class template named Vector in C++ with the following specifications:
• The class should have a private data member vector for the vector.
• A constructor that initializes the vector, and a destructor that deletes the vector.
• Get and set methods for the vector, and a method getSize that returns the size of the
vector.
• Overload the () operator to access elements of the vector. The function should throw
an exception if the index is out-of-bounds. Write a program that demonstrates the
functionality of the Vector class by doing the following:
• Create a few Vector objects and print their details.
• Access and modify elements of the vectors using the overloaded () operator.
Question 8 :Design a class named Ship in C++ with the following specifications:
• The class should have the following private data members: manufacturer (a string),
model (a string), and year (an integer).
• A pure virtual function named printDetails.
• A destructor that prints a message saying the ship is being deleted. Then, design two
classes named Yacht and Cruise that inherit from the Ship class. These classes should
override the printDetails function. Next, design a class named FlyingShip that inherits
from both the Yacht and Cruise classes (demonstrating multiple inheritance). This
class should also override the printDetails function. Finally, design a class named
VirtualYacht that virtually inherits from the Yacht class (demonstrating virtual
inheritance). This class should also override the printDetails function. Write a
program that demonstrates the functionality of the Ship, Yacht, Cruise, FlyingShip,
and VirtualYacht classes by doing the following:
• Create a few Yacht, Cruise, FlyingShip, and VirtualYacht objects and print their
details.
Question 9 :Design a class named Hospital in C++. The class should have the following
specifications:
Question 10 :Design a class named CEO in C++ with the following specifications:
Question 11 :Design a class template named Stack in C++ with the following specifications:
• The class should have a private data member stack for the stack.
• A constructor that initializes the stack, and a destructor that deletes the stack.
• Get and set methods for the stack, and a method getSize that returns the size of the
stack.
• Overload the () operator to access elements of the stack. The function should throw an
exception if the index is out-of-bounds. Write a program that demonstrates the
functionality of the Stack class by doing the following:
• Create a few Stack objects and print their details.
• Access and modify elements of the stacks using the overloaded () operator.
Question 12 :Design a class named Boat in C++ with the following specifications:
• The class should have the following private data members: manufacturer (a string),
model (a string), and year (an integer).
• A pure virtual function named printDetails.
• A destructor that prints a message saying the boat is being deleted. Then, design two
classes named Sailboat and Motorboat that inherit from the Boat class. These classes
should override the printDetails function. Next, design a class named FlyingBoat that
inherits from both the Sailboat and Motorboat classes (demonstrating multiple
inheritance). This class should also override the printDetails function. Finally, design
a class named VirtualSailboat that virtually inherits from the Sailboat class
(demonstrating virtual inheritance). This class should also override the printDetails
function. Write a program that demonstrates the functionality of the Boat, Sailboat,
Motorboat, FlyingBoat, and VirtualSailboat classes by doing the following:
• Create a few Sailboat, Motorboat, FlyingBoat, and VirtualSailboat objects and print
their details.
Question 13 :Design a class named School in C++. The class should have the following
specifications:
Question 14 :Design a class named Supervisor in C++ with the following specifications:
Question 15 :Design a class template named Queue in C++ with the following specifications:
• The class should have a private data member queue for the queue.
• A constructor that initializes the queue, and a destructor that deletes the queue.
• Get and set methods for the queue, and a method getSize that returns the size of the
queue.
• Overload the () operator to access elements of the queue. The function should throw
an exception if the index is out-of-bounds. Write a program that demonstrates the
functionality of the Queue class by doing the following:
• Create a few Queue objects and print their details.
• Access and modify elements of the queues using the overloaded () operator.
Question 16 :Design a class named Train in C++ with the following specifications:
• The class should have the following private data members: manufacturer (a string),
model (a string), and year (an integer).
• A pure virtual function named printDetails.
• A destructor that prints a message saying the train is being deleted. Then, design two
classes named FreightTrain and PassengerTrain that inherit from the Train class.
These classes should override the printDetails function. Next, design a class named
FlyingTrain that inherits from both the FreightTrain and PassengerTrain classes
(demonstrating multiple inheritance). This class should also override the printDetails
function. Finally, design a class named VirtualFreightTrain that virtually inherits from
the FreightTrain class (demonstrating virtual inheritance). This class should also
override the printDetails function. Write a program that demonstrates the functionality
of the Train, FreightTrain, PassengerTrain, FlyingTrain, and VirtualFreightTrain
classes by doing the following:
• Create a few FreightTrain, PassengerTrain, FlyingTrain, and VirtualFreightTrain
objects and print their details.