Lab05 Classes 1
Lab05 Classes 1
Problem 1:
Create a class coordinate plane that take two-point x, y and return the plan of the coordinates.
Create default constructor
Create parameterized constructors
Setters getter of the member variables
Function that will return the coordinate plane
Problem 2:
In ocean navigation, locations are measured in degrees and minutes of latitude and longitude.
Thus if you’re lying off the mouth of Papeete Harbor in Tahiti, your location is 149 degrees 34.8
minutes west longitude, and 17 degrees 31.5 minutes south latitude. This is Chapter 6 260 07
3087 CH06 11/29/01 2:16 PM Page 260 written as 149°34.8’ W, 17°31.5’ S. There are 60
minutes in a degree. (An older system also divided a minute into 60 seconds, but the modern
approach is to use decimal minutes instead.) Longitude is measured from 0 to 180 degrees, east
or west from Greenwich, England, to the international dateline in the Pacific. Latitude is
measured from 0 to 90 degrees, north or south from the equator to the poles.
Create a class angle that includes three member variables: an int for degrees, a float for
minutes, and a char for the direction letter (N, S, E, or W). This class can hold either a latitude
variable or a longitude variable.
Write setters and getters for each member variable.
Write a display function that will print the location.
Also write a three-argument constructor.
Problem 3:
Write a class to represent a vector (a series of int values). A pointer (vector), size of the vector;
Include member functions to perform the following tasks:
Default and parametrized constructor
Setter and getter of the vector
Multiply a scalar value to vector
Max value in the vector
Current size of the vector
Remove function that remove the element and update the size;
Isfull function to check whether vector is overflow or not
Problem 4:
We have a real world scenario where we have to simulate a park ticket system. A park has some
specific seating capacity, we also have ticket price, ticket number, and total amount we get for
the day. Price of ticket per head is Rs. 20/- . Write the following member functions
Default and parameterized constructor
Setters and getters
A function that perform entrance in the park (function has one argument the number of
persons going into the park)
On exit updating of the capacity (one argument how many people left the park)
Total amount we get for the day (return total amount of the day).
Isfull function that will check is there no more capacity in the park
Problem 5:
Create a class ‘Date’, with three private variables ‘day’, ‘month’, ‘year’. Write a no argument
constructor to iniatilize date to 01/01/1900. Also write
a three argument constructor Date (int day, int month, int year) to show
constructor overloading. Also create a destructor. Create two functions with following signatures:
● bool LeapYear (Date obj)
◆ Checking if the date is within a leap year
● int SubstractDate (Date obj1, Date obj2)
◆ Subtracting two dates to give a number of days