You are on page 1of 9

Assignment 1 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 2DSFs deep space observation array, and you need to develop a program that does the following: a) b) c) d) 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.

Task Requirements
A) 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. B) The LocationData class helps to store statistical data (such as sun type, no. of earthlike planets, etc) that will be keyed into your program. It also implements a formula to compute a locations 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.

Page 1 of 9

C) 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. D) 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)

Appendix E provides more information about implementing this class. E) 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. F) 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
1) The deliverables include the following: a) The actual working C++ program (soft copy), with comments on each file, function or block of code to help the tutor understand its purpose. b) 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) c) A program demonstration during lab session evaluation. You must be prepared to answer any questions posed by the tutor.

Page 2 of 9

2)

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.

Grading
Students deliverable will be graded according to the following criteria: (i) (ii) (iii) Program fulfills all the basic requirements stipulated by the assignment (7%) Successful demonstration of a working program, clarity of presentation and satisfactory answers provided during Q & A session. (2%) Additional effort (e.g. enhancing the program with relevant features over and above task requirements, impressive, killer presentation) (1%)

Page 3 of 9

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


Y Axis (mKM) 1 unit = 100 million Km

6 Distance between 2DSFs HQ (0,0) and the star system at sector (-4,4). Your program needs to compute the total travel distance, to all top 5 locations with the highest Civ Idx value!

-6

-4

-2

X Axis (mKM) 1 unit = 100 million Km

-2

-4

-6

Point2D (0, 0) the origin, it represents the sector in Flatspace where 2DSFs HQ is located

Point2D (5, -5) represents a sector in Flat-space where a star system, possibly with evolving lifeform, could be found! Each sector has a civilization index value, computed based on statistical data generated for that sectors location. The higher the value, the better the chances of discovering evolving life / civilization in that star system.

Page 4 of 9

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 sunType noOfEarthLikePlanet s noOfEarthLikeMoons Type String integer integer Remarks Different types sun has great influence on the possibility of life in the star system. The bigger this number, the better the chances that life can be found The bigger this number, the better the chances that life can be found Refers to density of particulates like sand, rocks, asteroids over the area of the star system. The lower the number, the better Refers to the density of radiation and gases averaged over the area of the star system. The lower the number, the better

aveParticulateDensity float avePlasmaDensity float

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 parameters 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 methods algorithm!

Page 5 of 9

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 rd 3 Parameter : noOfEarthLikeMoons, integer 4th Parameter: aveParticulateDensity, float 5th Parameter: avePlasmaDensity, float Algorithm 1st step, is to convert sunType into a percentage value sunTypePercent, based on the table below. sunType Type O Type B Type A Type F Type G Type K Type M %-tage value (possibility of supporting life ) 30% 45% 60% 75% 90% 80% 70% The ideal sun type that can support life should be close to G type star!

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

Page 6 of 9

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 : Remarks x The x-ordinate of the candidate star system, w.r.t. 2DSFs HQ (origin) y integer The y-ordinate of the candidate star system, w.r.t. 2DSFs 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 parameters 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 Name Type integer

Page 7 of 9

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.

Welcome to Mission Plan program! 1) 2) 3) 4) Input statistical data Compute civ. index value (for all records) Print top 5 exploration destinations Print total travel distance

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

Please enter your choice : 1 [ Input statistical data ] Please enter x-ordinate : 3 Please enter y-ordinate : 5 Please enter sun type : Type K Please enter no. of earth-like planets : 8 Please enter no. of earth-like moons : 13 Please enter ave. particulate density (%-tage) : 20 Please enter ave. plasma density (%-tage) : 10 Record successfully stored. Going back to main menu 1) 2) 3) 4) Input statistical data Compute civ. index value (for all records) Print top 5 exploration destinations Print total travel distance

Please enter your choice :

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!

Welcome to Mission Plan program! 1) 2) 3) 4) Input statistical data Compute civ. index value (for all records) Print top 5 exploration destinations Print total travel distance

Please enter your choice : 2 Computation completed! ( 3 records were updated )

Page 8 of 9

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 displated, sorted in descending order by Civ Idx value!

Welcome to Mission Plan program! 1) 2) 3) 4) Input statistical data Compute civ. index value (for all records) Print top 5 exploration destinations Print total travel distance

Please enter your choice : 3 Total no. of records available = 3 Printing top 5 exploration destinations 1) Civ Idx : 5.13, at sector (4, 3) 2) Civ Idx : 2.68, at sector (-2, -2) 3) Civ Idx : 1.03, at sector (3, -2) 4) <no other records available> 5) <no other records available> Done!

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

Welcome to Mission Plan program! 1) 2) 3) 4) Input statistical data Compute civ. index value (for all records) Print top 5 exploration destinations Print total travel distance

Please enter your choice : 4 Total (approx) travel distance = 2287 million km

Note 2 : Assuming there are only 3 records with Civ Idx computed, the total travel distance would be :

This total distance is computed based on the Top 5 exploration destinations in the previous figure.

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) !

Page 9 of 9

You might also like