1st Mandatory PDF
1st Mandatory PDF
1st Mandatory PDF
Implement and test the classes one by one on Eclipse (provide stubs as required)
Marking:
Implementation of class CWaypoint
Design and Questions
Implementation of all other Navigation
system classes
Source, Internet
3
3
3
1.1
Develop a class which stores a geodetic position and provides some simple operations for
geodetic data.
UML Diagram
(1-1)
90 latitude 90
180 longitude 180
(1-2)
a) Declare the class based on the UML diagram in the file CWaypoint.h.
b) Implement the set() method, which checks the validity of the parameter values (see
formula 1-2 above) and writes correct values to the attributes. In case of invalid parameter
values, a 0 shall be written to the attributes.
c) Implement the constructor in the file CWaypoint.cpp (provide default values). Use the
set()-method to store the parameter values. Print the address of the object using the
this Pointer as well as all attribute values and addresses. How much data is occupied by
the different attributes? Add a corresponding comment to the code! Hint: Use a the
preprocessor directive #ifdef SHOWADRESS to turn verbose mode on and off (by
#defineing SHOWADRESS)
d) Create four objects amsterdam, darmstadt, berlin and tokio in the main file. Google
the internet to find the latitude and longitude of these cities. Create another object
newWaypoint without parameter list.
e) Implement the print() method, which takes a parameter format. Depending on the
format value (1 or 2), the latitude and longitude are printed in decimal format or in deg mm
ss format. Implement the two private functions transformLongitude2degmmss() and
transformLatitude2degmmss() which translate the decimal attribute values into the
deg mm ss format. Hint: Check the printout at the end of the exercise for the required
format. Another hint: 60min or 3600s are equal to 1 deg.
f)
Add the code for printing berlin in both formats to the main file. Add two constants
DEGREE (value 1) and MMSS (value 2) using a #define statement. Which is the best file to
put the define?
g) Add the three getter functions getName(), getLatitude() and getLongitude() to your
code and provide a testcase for them in the main file.
h) Define three local variables name, longitude and latitude and use the method
getAllDataByReference() to return all waypoint of tokio data in a single call. Analyze
the addresses of the local variables name, longitude and latitude defined in the main file
and compare them with the parameter addresses and values (using cout or the
debugger). Describe your findings as comment in the code!
i)
Implement the function calculateDistance() using the formulas above. Add a testcase
to the main file calculating the distance between amsterdam and berlin and berlin
and tokio.
Constructor
===========
print method
============
Berlin on latitude = 52.5166 and longitude = 13.4
Berlinon latitude = 52deg 30min 59.76s and longitude = 13deg 24min 1.27896e-012s
Name as return value: Amsterdam
and a first real method
=======================
Distance between Amsterdam and Berlin: 577.145
Distance between Tokio and Berlin: 8928.78
1.2
Complete the design and answer all questions before you start coding.
Design
Add all class relations to the design. Do not forget to provide dependencies.
e) Draw an Activity diagram for the method addPoi(string namePoi). Make sure that all
methods called from other classes are visible as activities.
Implementation
f)
Determine a sensible order of implementation. Which classes are you going to implement
first?
The testcases itself shall be implemented as private functions which are called from
the CNavigationSystem::run() Method (see class diagram)
Sample output:
ERROR: Could not find POI Something not in the pool
Our Route has 3 Waypoints and 2 Points of Interest
Amsterdam on latitude = 52deg 22min 23.16s and longitude = 4deg 53min 31.92s
Darmstadt on latitude = 49deg 51min 5.11583e-012s and longitude = 8deg 39min 9.72s
Berlin on latitude = 52deg 30min 59.76s and longitude = 13deg 24min 1.27896e-012s
Point of Interest
=================
of type Restaurant : The best Mensa in the world
Mensa HDA on latitude = 10deg 0min 0s and longitude = 20deg 0min 0s
Point of Interest
=================
of type Restaurant : More expensive but also good
Sitte on latitude = 11deg 0min 0s and longitude = 22deg 0min 0s
GPS Sensor
Enter latitude: 15
Enter longitude: 10
Distance to next POI = 1220.61
Point of Interest
=================
of type Restaurant : The best Mensa in the world
Mensa HDA on latitude = 10deg 0min 0s
10