Department of Computer Science
University of Engineering and Technology, Lahore
________________________________________________________________________
Problem 1:
Case Study:
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 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 one member function to change the angle value (in degrees and minutes) and a direction given
from the user, and a second to display the angle value in 179°59.9’ E in string format. Also write a
three-argument constructor.
You can use this to print a degree (°) symbol.
[Link]("\u00b0");
Create a class called ship that incorporates a ship’s number and location. Use two variables of the angle
class to represent the ship’s latitude and longitude for the ship’s location. Write a parameterized
constructor to initialize the attributes of the ship class. A member function of the ship class should print
the position (latitude and longitude) of the ship; another should report/print the serial number.
Your Tasks:
Task 1: Identify the Classes and Make the Class Diagram by adding the relation, multiplicity and
collaboration Step by Step
Task 2:
Maintain a list of ships in the main.
Driver Program Menu:
1. Add Ship
2. View Ship Position
3. View Ship Serial Number
4. Change Ship Position
5. Exit
If the user Enters 1 then
Enter Ship Number: “123TG”
Enter Ship Latitude:
Enter Latitude’s Degree: 149
Enter Latitude’s Minute: 34.8
Enter Latitude’s Direction: W
Enter Ship Longitude:
Enter Longitude’s Degree: 17
Enter Longitude’s Minute: 31.5
Enter Longitude’s Direction: S
If the user Enters 2 then
Enter Ship Serial Number to find its position: “123TG”
Ship is at 149°34.8’ W and 17°31.5’ S
If the user Enters 3 then
Enter the ship latitude: “149°34.8’ W”
Enter the ship longitude: “17°31.5’ S”
Ship’s serial number is 123TG
If the user Enters 4 then
Enter Ship’s serial number whose position you want to change: “123TG”
Enter Ship Latitude:
Enter Latitude’s Degree: 170
Enter Latitude’s Minute: 3.8
Enter Latitude’s Direction: E
Enter Ship Longitude:
Enter Longitude’s Degree: 12
Enter Longitude’s Minute: 39.5
Enter Longitude’s Direction: W
Problem 2:
Identify the Classes from your Business Application and Draw the Class Diagram and Implement your
Business Application with Separate Classes in BL Folder.
Problem 3:
Identify the Classes from your Project and Draw the Class Diagram and Implement your Game with
Separate Classes in BL Folder.