# Assignment 1 Mission Plan program Solved

Aim

The objectives of this assignment includes:

Learning about classes, objects, functions and composition
Apply the concepts learnt by developing a space travel planning program
Background

In a theoretical flat-land universe, everything is in 2 dimensions. People, animals, plants to planets, moons, galaxies and even space itself, is in 2D. In our flat-land space (i.e. ‘flat-space’), there is a powerful organization called 2D-StarFleet (2DSF), whose goals include seeking out new life and civilization via exploration.

For this assignment, you take on the role of a mission planning specialist. You are supplied with statistical data from 2DSF’s deep space observation array, and you need to develop a program that does the following:

read in statistical data (via manual input)
compute the likelihood of life / civilization evolving in each location
prioritize a list of top 5 locations for flat-space exploration
compute total travel distance based on priority in c)
You need to develop a minimum of 3 classes : PointTwoD, LocationData and MissionPlan.  The next section describes the requirements for each of these classes.

2DSF has adopted a mapping coordinate system with its current headquarters as the origin. Please refer to Appendix A, which elaborates on this coordinate system, the unit representation and relative positioning of different star systems.

The LocationData class helps to store statistical data (such as sun type, no. of earth-like planets, etc) that will be keyed into your program. It also implements a formula to compute a location’s civilization index, to help determine if this star system is worth travelling millions of kilometers to check out. Appendices B & C provides more information about implementing this class.

The PointTwoD class helps to store (x, y) coordinate info, and encapsulates a LocationData object that stores the star system data pertaining to the coordinate position. It should be noted that information stored within LocationData objects are classified ‘secret’, and should not be stored / accessed elsewhere, other than via PointTwoD object ! Appendix D provides more information about implementing this class.

The MissionPlan class is the main driver class whose methods are called to start the program. When started, it should print a menu providing the following functionalities :

Allow user to input the statistical data
Compute the civilization index (based on all statistical data entered so far)
Print top 5 exploration destinations (based on all location data available)
Total travel distance (to explore all recommended destinations)

Once the program is completed and tested to be working successfully, you are highly encouraged to add on “new features” to the program that you feel are relevant to the problem. Additional marks may be awarded subject to the relevancy and correctness of the new functionalities.

You are to use only C++ language to develop your program. There is no restriction on the IDE as long as your source files can be compiled by g++ compiler (that comes packaged in Ubuntu Linux) and executed in the Ubuntu terminal shell environment.

Deliverables

The deliverables include the following:

The actual working C++ program (soft copy), with comments on each file, function or block of code to help the tutor understand its purpose.

A softcopy word document that elaborates on:(Interpreted) requirements of the program
Diagram / Illustrations of program design
Summary of implementation of each module in your program
Reflections on program development (e.g. assumptions made, difficulties faced, what could have been done better, possible enhancements in future, what have you learnt, etc)

A program demo/evaluation during lab session. You must be prepared to perform certain tasks / answer any questions posed by the tutor.

IMPT: Please follow closely, to the submission instructions in Appendix F, which contains details about what to submit, file naming conventions, when to submit, where to submit, etc.

The evaluation will be held during lab session where you are supposed to submit your assignment. Some time will be allocated for you to present / demonstrate your program during the session.

Student’s deliverable will be graded according to the following criteria:

Program fulfills all the basic requirements stipulated by the assignment

Successful demonstration of a working program, clarity of presentation and satisfactory answers provided during Q & A session.

Additional effort (e.g. enhancing the program with relevant features over and above task requirements, impressive, ‘killer’ presentation)

After the submission of deliverables, students will be required undergo an evaluation process (to determine fulfillment of task requirements.) Further instructions will be given by the Tutor during the subsequent respective labs. Please pay attention as failure to adhere to instructions may result in deduction of marks.

Tutor’s note:

In the real working world, satisfactory completion of your tasks is no longer enough. The ability to add value, communicate and/or demonstrate your ideas with clarity is just as important as correct functioning of your program. The grading criteria is set to imitate such requirements on a ‘smaller scale’.

APPENDIX A

(Coordinate System of 2D Star Fleet, in Flat-Space)

APPENDIX B

(Implementation info for : LocationData)

Note :

The section below describes the compulsory requirements for class constructors, attributes and methods. However, you are free to implement any additional attributes / methods, as long as it is related to the purpose of the class.

Class Name : LocationData

Attributes :

Name
Type
Remarks
sunType
String
Different types sun has great influence on the possibility of life in the star system.
noOfEarthLikePlanets
integer
The bigger this number, the better the chances that life can be found
noOfEarthLikeMoons
integer
The bigger this number, the better the chances that life can be found
aveParticulateDensity
float
Refers to density of particulates like sand, rocks, asteroids over the area of the star system. The lower the number, the better
float
Refers to the density of radiation and gases averaged over the area of the star system. The lower the number, the better

Constructors :

1st Constructor –

no parameters. Initialize all String variables to empty string, all int and float variables to 0.

2nd Constructor –

5 parameters. Initialize all attribute variables to the parameter’s values respectively.

Methods :

Assessor (get) and Mutator (set) for each attribute(s)
toString() method that returns a String, containing the name of each attribute and its value respectively
static method computeCivIndex()    Note : refer to Appendix C, for this method’s                                                                                          algorithm!

APPENDIX C

(Implementation algorithm for : computeCivIndex())

Return type

A float value, (the higher this value, the greater the possibility of life in the star system)

Parameters (arguments)

1st Parameter            : sunType, String

2nd Parameter           : noOfEarthLikePlanets, integer

3rd Parameter            : noOfEarthLikeMoons, integer

4th Parameter            : aveParticulateDensity, float

Algorithm

1st step, is to convert sunType into a percentage value ‘sunTypePercent’, based on the table below.

sunType
%-tage value

(possibility of supporting life …)
“Type O”
30%
“Type B”
45%
“Type A”
60%
“Type F”
75%
“Type G”
90%
“Type K”
80%
“Type M”
70%

2nd step, is to compute based on the formula below:

Civ. Index =

[ (sunTypePercent / 100) – (aveParticulateDensity + avePlasmaDensity)  / 200 ]  x

[ noOfEarthLikePlanets +  noOfEarthLikeMoons ]

E.g.  Assuming :

sunType = “Type B”, aveParticulateDensity = 20%, avePlasmaDensity  = 50%, noOfEarthLikePlanets = 5, noOfEarthLikeMoons  = 10, then

Civ. Index = [ (45/100) – (20 + 50) / 200 ] x [ 5 + 10 ] = 1.5

APPENDIX D

(Implementation info for : PointTwoD)

Note :

The section below describes the compulsory requirements for class constructors, attributes and methods. However, you are free to implement any additional attributes / methods, as long as it is related to the purpose of the class.

Class Name : PointTwoD

Attributes :

Name
Type
Remarks
x
integer
The x-ordinate of the candidate star system, w.r.t. 2DSF’s HQ (origin)
y
integer
The y-ordinate of the candidate star system, w.r.t. 2DSF’s HQ (origin)
locationData
LocationData
The statistical data about the star system, tied to this (x, y) coordinate
civIndex
float
The computed civilization index value should be stored here

Constructors :

1st Constructor –

no parameters. Initialize all String variables to empty string, all int and float variables to 0.

2nd Constructor –

3 parameters. Initialize all attribute variables to the parameter’s values respectively.

Methods :

Assessor (get) and Mutator (set) for each attribute(s)
toString() method that returns a String, containing the name of each attribute and its value respectively

APPENDIX E

(Implementation info for : MissionPlan class)

This class contains the main () method which declares and instantiates all other classes (i.e. LocationData, PointTwoD) and sets up all the necessary interactions to perform its task.

The figure on the left describes a sample interaction between the main menu and ‘Input statistical data’ sub-menu

The figure on the right describes a sample interaction between the main menu and ‘Compute civ. index value (for all records)’ function.

Note : The example assumes the case where there has only been 3 statistical data records input so far, hence, the message that ‘3 records were updated’!

The figure on the right describes a sample interaction between the main menu and ‘Print top 5 exploration destinations’ function.

Note : The example assumes the case where there has only been 3 statistical data records input so far. Hence all records are displayed, sorted in descending order by Civ Idx value!

The figure on the right describes a sample interaction between the main menu and ‘Print total travel distance’ function.

Note 1 : The formula to compute a straight line distance between 2 points on the map is …

Note 2 : Assuming there are only

3 records with Civ Idx computed,

the total travel distance would be :

dist (HQ to Star Sys. 1) + dist (Star Sys. 1 back to HQ to re-fuel) +

dist (HQ to Star Sys. 2) + dist (Star Sys. 2 back to HQ to re-fuel) +

dist (HQ to Star Sys. 3) + dist (Star Sys. 3 back to HQ to re-fuel)

= 2 (d1 + d2 + d3)

Note 3 : If there are more than 5 records (e.g. 15), then total travel distance should compute the total distances for the trips to the top 5 exploration destinations output by your menu choice 3) !

APPENDIX F

Submission Instructions  (V. IMPT!!)

Deliverables

All submissions should be in softcopy, unless otherwise instructed

For the actual files to be submitted, you typically need to include the following:

word document report (e.g. *.doc), save as MS Word 97-2003 format

the source file(s), (e.g. *.h, *.o, or *.cpp files)

the executable file, compile into an executable file with *.exe
(e.g. Assn1.exe)

How to package

Compress all your assignment files into a single zip file. Please use the following naming             format :

<FT/PT_Assn1_<Stud. No._<Name.zip

Example :  FT_Assn1_1234567_JohnDoeAnderson. zip

<FT/PT Use “FT” for Full-Time student, “PT” if you are Part-Time student

Assn1 if you are submitting assignment 1, Assn2 if submitting assignment 2

<Stud. No. refers to your UOW student number (e.g. 1234567)

<Name refers to your UOW registered name (e.g. JohnDoeAnderson)

Where to submit

In the event of UNFORSEEN SITUATIONS :

( E.g.  Student's moodle account not ready, cannot login to moodle, eLearning site down on submission day, unable to upload assignment, etc )

[email protected]      for FULL TIME students

[email protected]      for PART TIME students

In your email subject line, type in the following information :

<FT/PT <assignment info <student number and <name.

Example:

To                   :           tutor's email (see above)

Subject          :           FT Assn1 1234567 JohnDoeAnderson

Note 1 :         The timestamp shown on tutor’s email Inbox will be used to determine if the                               assignment is late or not.

Note 2 :         After email submission, your mailbox’s  sent folder  would have a                                         copy (record) of your sent email, please do not delete that copy !!  It could                                     be used to prove your timely submission, in case the Tutor did not receive                                     your email!

When to submit

Depending on the time-table, a demo / evaluation for your assignment may be scheduled during the:3rd - 5th lab session for the semester (i.e. lab 3 - 5), for Full Time (FT) students
2nd - 4th lab session for the semester (i.e. lab 2 - 4), for Part Time (PT) students

Please consult your tutor for further details. Some time may be allocated for each student to present / explain your system design during the session.

Please refer to the following table on the different submission events and deadlines

Assignment

(latest by 2300 hrs)
Email Evaluation files by :

PT
FT
1
23 / 10 / 2016
26 / 10 / 2016
Lab 2(PT), Lab 3(FT)
End of Lab 2(PT), Lab 3(FT)
2
01 / 11 / 2016
02 / 11 / 2016
Lab 3(PT), Lab 4(FT)
End of Lab 3(PT), Lab 4(FT)
3
13 / 11 / 2016
15 / 11 / 2016
Lab 4(PT), Lab 5(FT)
End of Lab 4(PT), Lab 5(FT)

Note: (PT) = Part Time Students, (FT) = Full Time Students !

Example #1, for Full Time (FT) students submitting Assignment 1 ...

Submit your zip file to Tutor by 26 / 10 / 2016, 2330 hrs

Setup your Assn 1 program for evaluation on the date of : Lab 3

Finish evaluation tasks, email Assn 1 evaluation files by end of : Lab 3

Example #2, for Part Time (PT) students submitting Assignment 3 ...

Submit your zip file to Tutor by 13 / 11 / 2016, 2330 hrs

Setup your Assn 3 program for evaluation on the date of : Lab 4

Finish evaluation tasks, email Assn 3 evaluation files by end of : Lab 4

! VERY IMPORTANT !

IF YOU ARE NOT SURE,

OR ...

MARKS WILL BE DEDUCTED IF YOU FAIL TO FOLLOW INSTRUCTIONS !!

Example :

You have no email subject

Wrong naming or misleading information given
(e.g. putting “Assn2” in email subject, when you are submitting “Assn1”)

(e.g. naming “Assn1” in your zip file, but inside contains Assn2 files )

Your report cannot be opened by Microsoft Word 2003
Your program cannot be re-compiled and/or executable file cannot run
You email to the WRONG tutor

After the deadline, (on case-by-case basis), some students / grp may be granted             an opportunity for an un-official resubmission by the tutor. If this is so, please adhere to the following instructions carefully:

<Step 1

Zip up for re-submission files according to the following format :

<FT/PT_Assn1_Resubmit_v1_<Stud. No. _<Name.zip

Example :  FT _ Assn1_Resubmit_v1_1234567_JohnDoeAnderson. zip

<FT/PT Use “FT” for Full-Time student, “PT” if you are Part-Time student

Assn1 if you are submitting assignment 1, Assn2 if submitting assignment 2

Resubmit_v1 if this is your 1st re-submission

Resubmit_v2 if this is your 2nd re-submission

<Stud. No. refers to your UOW student number (e.g. 1234567)

<Name refers to your UOW registered name (e.g. JohnDoeAnderson)

IMPT - To prevent Tutor’s Inbox from blowing up in his face, each student is only allowed to re-submit twice, for each assignment only!

<Step 2

Please email your single zip file to your tutor's email (refer to section 3) - Where to submit)

In your email subject line, type in the following information :

<FT/PT <assignment info  <re-submission ver. <student number and <name

Example:

To                   :           tutor's email (refer to section 3) - Where to submit)

Subject          :           FT Assn1 Resubmit_v1 1234567 JohnDoeAnderson