Starting from:

$34.99

CSCI262 Assiqnment 2 Solution

Aim
The objectives of this assignment includes.
• Learning about encapsulation, inheritance, polymorphism and function overloading
• Apply the concepts learnt by developing a survey and path planning program
Backqround
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.
While on a routine mission of exploration, the flagship of 2DSF, the Enterprise-2D is trapped in an expanse of space encircled by a massive ring of violent, electrical plasma storm. Data coming in from the sensor array reveals that the only opening in this storm is located at the far end of the enclosed area, from Enterprise-2D's current location.
In addition, the sensor data also revealed that this area is populated by strange, 2D geometrical shapes, with sizes ranging from a small moon, asteroid, to large planets, or even a star! This implies that to travel to the 'exit' at the far end of the storm, you need to understand more about the properties of these shapes and attempt to chart a course to navigate to the exit!
As a Science Officer aboard Enterprise-2D, you need to develop a program that has the following capabilities.
a) read in sensor data on the strange 2D shapes (via manual input)
b) compute the area ('mass') of these shapes
c) print shapes report (e.g. list of points: on its perimeter, or totally within shape's area)
d) sort shapes data (sorted by special type and area)
The next section provides information about the requirements for developing this program.
Task Requirements
IMPORTANT : For this assignment, you should not assume that the 2D shapes in Appendix A are positioned exactly as shown in Appendix A, nor that there are not more shapes. There will, however, only be shapes of the types listed in Appendix B
B) The sensor data coming in from Enterprise-2D's sensor array provides crucial information about the 2D shapes such as name, special type and location of all vertices (that outlines the perimeter of the shape). Please refer to Appendix B, which provides a more detailed description of the sensor data.
C) To assist you in the initial class design of your program, please refer to Appendix C, which illustrates one possible way of designing your program. It also describes a list of requirements which you need to implement, especially those marked under "compulsory" The classes highlighted in Appendix C are purely meant to store data about the 2D shapes entered into your program by user.
D) You are required to implement a main driver class called 'Assn2', whose methods are called to start the program. When started, it should print a menu providing the following functionalities
• read in sensor data on the strange 2D shapes (via manual input)
• compute the area ('mass') of these shapes print shapes report (e.g. list of points on its perimeter, or totally within shapes area)
• sort shapes data (sorted by special type and area)
Appendix D provides more information about implementing this class.
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:
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)
2) IMPT: Please follow closely, to the submission instructions in Appendix E, which contains details about what to submit, file naming conventions, when to submit, where to submit, etc.
3) The software demo / testing 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's capabilities during the session.
Gradinq
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 explanation / 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)
In the real working world, satisfactory completion of your tasks is no longer enough. The capability, efficiency and robustness of your system to operate under different testing conditions, and 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'

A
(Coordinate System w.r.t. Enterprise-2D, and the plasma storm)
Y Axis (mKM)
1 unit = 10 million Km
X Axis (mKM) 1 unit =
10 million Km
Enterprise-2D is trapped in this huge ring of electrical plasma storm. The only opening to exit this storm is located in the far 'upper-right' of the coordinate system, for e.g. at Point2D (14, 14) !
B

(Description of Sensor Data)
Name
The name of the 2D shape reveals the general type of shape encountered. Currently, the values consist of : "Square", "Rectangle", "Cross" and "Circle"
Special Type
Enterprise-2D's sensor has detected that some shapes encloses a 'warp-space' with the amazing ability to teleport any objects that touches one of its vertex, to any other vertices of the same shape, instantaneously !
This makes it highly desirable, for Enterprise-2D to travel towards this kind of shape, in the hopes of travelling faster, and saving precious fuel at the same time!
There are only 2 values for 'special type' : "WS" (Warp-Space) or "NS" (Normal-Space).
Vertices
The vertices is actually a set of (x, y) points, that describes the outline of the 2D shape. The number of points in the set, depends on the name of the shape. The table below summarizes the kind of sensor data your program expects to receive.
Name Special Type No. of Vertices
(i.e. x, y, points) Actual Vertex Data
"Cross" "WS" or "NS" 12 e.g. (1 , 3), (1 , 4), etc.
"Square" "WS" or "NS" 4
"Rectangle" "WS" or "NS" 4

Note :
As mentioned in the Background section, the 1 st capability of your program should allow manual input of the above data.
It is not necessary to prompt user for "No. of Vertices" because the name of the shape will already inform your program about how much vertex data to expect.
For example, when your program prompt for name of the shape, if user enters "Cross", it is safe for your program to assume that user is going to key a set of 12 (x, y) points later!
C

(Implementation Requirements)
ShapeTwoD
# name: string
# containsWarpSpace: bool
+ ShapeTwoD (name: string, containsWarpSpace: bool)
+ getName 0 : string
+ getContainsWarpSpace () : bool
+ toString 0 : string
+ computeArea 0 : double
+ isPointlnShape (x: int, y: int) : bool
+ isPointOnShape (x: int, y: int) : bool
+ setName (name: string)
+ setContainsWarpSpace (containsWarpSpace: bool)


Compulsory requirements
The parent class is 'ShapeTwoD'. Any attributes, constructors and methods specified in the diagram must be implemented, with the exact same name, parameter, type and access!
#2 The sub-classes of ShapeTwoD must be named 'Cross Square', 'Circle' and
'Rectangle
#3 The method 'toString ( ) in class ShapeTwoD is a virtual function that returns a string containing all the values of the attributes in the shape, excluding the array of vertex data. (However, sub-classes of ShapeTwoD must output the array of vertex data, inclusive of any other attribute's values it inherited)
#4 The method 'computeArea ( ) in class ShapeTwoD is a virtual function. It must be override by the sub-classes and implemented individually.
For example, because each sub-class has different number of vertices and values, subclass Cross's computeArea ( ) implementation would use a different algorithm / formula from sub-class Square's computeArea ( ) implementation!
Note The sensor data will only provide the locations (vertices) of each 2D shape encountered. You will be required to do the necessary research to derive the formula to compute the area for each shape, based on the set of vertex data (i,e. a set of [ x, y ] points) provided!
#5 The method 'is PointlnShape ( ) in class ShapeTwoD is a virtual function. It takes in a [ x, y ] location and returns a boolean value indicating whether the location is totally within the shape's area. It must be over-ridden by the sub-classes and implemented individually. (PIs refer to sample output in Appendix D)
#6 The method 'is PointOnShape ( ) in class ShapeTwoD is also a virtual function. It takes in a [ x, y ] location and returns a boolean value indicating whether the location is found on any lines ioininq the shapes' vertices! It must be over-ridden by the subclasses and implemented individually. (PIs refer to sample output in Appendix D)
Other requirements
i) For parent class 'ShapeTwoD'. You are free to add on any additional methods or attributes deemed necessary for your program to provide its services.
Since user will key in the name of the shape, it is possible for you to declare arrays of fixed sizes in the sub-classes to store the coordinate vertices of the shape!
iii) You are free to implement any other additional classes you feel necessary so as to provide the required capabilities for this program.
APPENDIX D
(Implementation info for : Assn2 driver class)
This class contains the main () method which declares and instantiates all other classes (i.e. Shape2D, Square, etc) and sets up all the necessary interactions to perform its task.
Student ID : 1234567
Student Name : Tan Ah Meng Elvis

Welcome to Assn2 program!
1) Input sensor data
2) Compute area (for all records)
3) Print shapes report 4) Sort shape data
Please enter your choice .
[ Input sensor data ]
Please enter name of shape : Cross
Please enter special type .• ws
Please enter x-ordinate of pt. 1 : 1 Please enter y-ordinate of pt. 1 : 1
Please enter x-ordinate of pt. 12 .
Please enter y-ordinate of pt. 12 : 2
Record successfully stored. Going back to main menu .
Student ID : 1234567
Student Name : Tan Ah Meng Elvis

Student ID : 1234567
Student Name : Tan Ah Meng Elvis

Welcome to Assn2 program!
1) Input sensor data
2) Compute area (for all records)
3) Print shapes report 4) Sort shapes data
Please enter your choice .
Computation completed! ( 5 records were updated )
The figure on the left describes a sample interaction between the main menu and 'Input sensor data' sub-menu (1 example)
Note :
Impt !! Please include your:
1. Student ID
2. Student Name
every time you display your Main Menu. Marks will be deducted if the required info is not shown.
The figure on the right describes a sample interaction between the main menu and 'Compute area (for al/ records)' function.
Note The example assumes the case where t re only 5 shapes input so far, hence, the message that '5 records were updated'!
In this compute area function, you must exhibit polymorphic behavior and dynamic bindinq by invoking the correct function for each shape stored in the Shape2D array !
Student ID : 1234567
Student Name : Tan Ah Meng Elvis

Welcome to Assn2 program!
1) Input sensor data
2) Compute area (for all records)
3) Print shapes report 4) Sort shape data
Please enter your choice .
[ Input sensor data ]
Please enter name of shape : Circle Please enter special type .
Please enter x-ordinate of center .•5
Please enter y-ordinate of center : 7
Please enter radius (units) : 2
Record successfully stored. Going back to main menu .
Student ID : 1234567
Student Name : Tan Ah Meng Elvis

The figure on the left describes a sample interaction between the main menu and 'Input sensor data' sub-menu (2 nd example)
Note For circle, there is no need to enter vertices, as there are no "corners" as opposed to other multi-sided polygon shape. Instead, just prompt user to enter the [x, y] of its center and its radius, as shown on the left
on the right describes a interaction between the main 'Print shapes report' function.
The example assumes the case there has only been 5 sensor input so far.
perimeter' refers to only those on the line drawn between 2 for each pair of vertices the shape's outline. Student ID : 1234567
Student Name : Tan Ah Meng Elvis

Welcome to Assn2 program!
1) Input sensor data
2) Compute area (for all records)
3) Print shapes report 4) Sort shapes data
Please enter your choice .
Total no. of records available = 5
Shape [0]
Name : Square
Special Type : WS Area : 4 units square Vertices :
Point[O] .• (1, 1)
Point [1] : (1, 3)
Point [2] : (3, 3)
Point
Points on perimeter : (1,2), (2, 1), (2, 3), (3, 2)
Points within shape : (2, 2)
Shape [4]
Name : Rectangle
Special Type : NS Area : 8 units square Vertices :
Point (2, 17)
Point (2, 15)
Point (6, 15)
Point (6, 17)
Points on perimeter: (2, 16), (3, 15), (4, 15), (5, 15), (6, 16), (5, 17), (4, 17), (3, 17)
2) lies on a line betw en 1) and (1, 3) !
need to include those points describe the vertices of the shape!
within shape' refers to those which are totally within the
need to include
points which de cribe the of the shape!
points on the peri eter of shape!
Points within shape : (3, 16), (4, 16), (5, 16)
The figure sample menu and
Notes where data records
'Points on points lying vertices, defining
E.g. (1 , vertices (1 ,
You do not which
'Points points shape.
You do not
those vertices
those the

Student ID : 1234567
Student Name : Tan Ah Meng Elvis

Welcome to Assn2 program!
1) Input sensor data
2) Compute area (for all records)
3) Print shapes report
4) Sort shapes data
Please enter your choice .• 4
a) Sort by area (ascending)
b) Sort by area (descending)
c) Sort by special type and area
Please select sort option ('q' to go main menu) : b
Sort by area (largest to smallest)
Shape [4]
Name : Rectangle
Special Type : NS Area : 8 units square Vertices :
Point (2, 17)
Point [1] : (2, 15) Point (6, 15)
Point (6, 17)
Points on perimeter: (2, 16), (3, 15), (4, 15), (5, 15), (6, 16), (5, 17), (4, 17), (3, 17)
Points within shape : (3, 16), (4, 16), (5, 16)
Shape [2]
Name : Square
Special Type : WS Area : 1 units square
Vertices :
Point [0] : (6, 6)
Point [1] : (6, 7) Point [2] : (7, 7)
Point : (7, 6)
Points on perimeter : none!
Points within shape : none!
The figure on the right describes a sample interaction between the main menu and 'Sort shapes data' sub-menu.
Note For 'sort by special type and area' option in the sub-menu, shapes with special types 'WS' should be displayed first, followed by all shapes with special types 'NS'.
Within each group of shapes (i.e. WS or NS), display the shapes in descending order!
APPENDIX E
Submission Instructions (V. IMP T!!)
1) Deliverables
a) All submissions should be in softcopy, unless otherwise instructed
b) 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, *.0, or *.cpp files)
the executable file, (using Ubuntu g++ compiler), compile into an executable filename with *.exe (e.g. csci251 a2.exe)
2) How to package
Compress all your assignment files into a single zip file. Please use the following naming format .

Example : FT TutGrp3 A2 1234567_JohnDoeAnderson.zip
< FTI p Use for ull- ime student if you are Part-Time student
<Your Grp refers to your SIM tutorial group (e.g. TutGrp1 / TutGrp2 / TutGrp3 / etc.)
A if you are submitting assignment , A3 if submitting assignment 3 etc.
<Stud. No.> refers to your I-JOW student number (e.g. 1234567)
<Name> refers to your I-JOW registered name (e.g. JohnDoeAnderson)
3) Where to submit
Please submit your assignment via Moodle el-earning site.
IMPORTANT NOTE :
• To minimize the chances of encountering UNFORSEEN SITUATIONS (mentioned below), please do an EARLY SUBMISSION via Moodle.
In the event of UNFORSEEN SITUATIONS :
csci251@yah00.com for FULL TIME students csci251@yah00.com for PART TIME students
In your email subject line, type in the following information
<FTIPT> <Your Grp <assignment inf0> <student number> and ìkname>

Example:
Subject FT TutGrp3 A'2 1234567 JohnDoeAnderson
sent folder
4) When to submit
a) Depending on the time-table, a software demo / testinq / presentation for your assignment will be scheduled during the:
3 rd - 5th lab session for the semester (i.e. lab 3 - 5), for Full Time ( ) students
2 nd - 4th lab session for the semester (i.e. lab 2 - 4), for Part Time (P T) students
b) Please refer to the following table on the different deliverables, submission events & deadlines
Testing (test cases), during . Email Test Case Result files by :

1 Lab 2 Lab 3 Lab 2(PT), Lab End of Lab 2(PT), Lab 3(FT)
2 Lab 3 Lab 4 Lab 3(PT), Lab 4(FT) End of Lab 3(PT), Lab 4(FT)
3 Lab 4 Lab 5 Lab 4(PT), Lab End of Lab 4(PT), Lab 5(FT)

5) Please help by paying attention to the following
! VERY IMPORTANT !
PLEASE FOLLOW ALL THE GUIDELINES / REQUIREMENTS IN ALL ASSIGNMENT APPENDICES
PLEASE FOLLOW ALL THE SUBMISSION INSTRUCTIONS FROM 1 TO 4
IF YOU ARE NOT SURE
OR
MARKS WILL BE DEDUCTED IF YOU FAIL TO FOLLOW INSTRUCTIONS
Examples of marks deduction
Your deliverables / zip file does not follow naming convention
You have no email subject / or do not following naming convention
Wrong naming or misleading information given
(e.g. putting "A2" in email subject, when you are submitting "Al ")
(e.g. naming "Al" in your zip file, but inside contains A2 files )
Your submission cannot be downloaded and unzipped
Your program cannot be re-compiled and/or executable file cannot run
Your report / testing files cannot be opened by Microsoft Word / Excel 2003 You did not submit / incomplete submission of software demo / testing files etc
6) Re-submission administration
< Step 1> Prepare 2 zip files as follows
Zip up for re-submission, program files according to the following format
Resubmit <Your Grp A'2 <Stud. No.>
Example : Resubmit FT TutGrp3 A'2 1234567 JohnDoeAnderson.zip
Zip up for re-submission, test case results files according to the following format .
Resubmit <Your A'2 TCResuIts <Stud. No.> <Name>.zip
Example : Resubmit FT TutGrp3 A'2 TCResuIts 1234567 JohnDoeAnderson.zip
< FTI p Use for Full-Time student if you are Part-Time student
<Your Grp refers to your SIM tutorial group (e.g. TutGrp1 / TutGrp2 / TutGrp3 / etc.)
A if you are submitting assignment , A3 if submitting assignment 3 etc.
<Stud. No.> refers to your I-JOW student number (e.g. 1234567)
<Name> refers to your I-JOW registered name (e.g. JohnDoeAnderson)
< Step 2>
In your email subject line, type in the following information
Resubmit <FTIPT> <Your Grp <assignment inf0> <student number> and <name>
Example.
Subject Resubmit FT TutGrp3 A'2 1234567 JohnDoeAnderson
IMPORTANT NOTE
Non-submission of any of the above mentioned files, or failure to adhere to submission instructions will result in ZERO marks!

More products