Q1: Write a class named as Bus that contains the attributes which are mentioned below: The name of Bus. The direction of Bus (North (N), South(S), East(E), West (W)) The position of Bus (from imaginary zero point) The class has the following member functions: A constructor to initialize the attributes Turn function to change the direction of bus to one step right side (e.g if the direction is to East, it should be changed to South and so on) Overload the Turn function to change the direction to any side directly. It should take the direction as an argument. Move function to change the position of the Bus away from imaginary zero point. It should accept the distance as an argument.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Q1: Write a class named as Bus that contains the attributes which are mentioned below:
The name of Bus.
The direction of Bus (North (N), South(S), East(E), West (W))
The position of Bus (from imaginary zero point)
The class has the following member functions:
A constructor to initialize the attributes
Turn function to change the direction of bus to one step right side (e.g if the direction is
to East, it should be changed to South and so on)
Overload the Turn function to change the direction to any side directly. It should take the
direction as an argument.
Move function to change the position of the Bus away from imaginary zero point. It
should accept the distance as an argument.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images