AimThe objectives of this assignment includes:Learning about generic programming templates, operator overloading, STL (containers & algorithms) and writing io manipulatorsApply the concepts learnt by developing a data processing program
Background
In this assignment, you are required to develop a program that reads in and process some messy records from a file that contains data meant for different kinds of classes. These data are jumbled up and unsorted, and to make it worse, for any particular row of record, there may be multiple duplicates scattered over the entire file!You program should be called Assn3, and should posses the following capabilities:
a) read in the records from a user-specified filename
b) remove all duplicate rows of data
c) filter and display the data according to user-specified sorting criteria
d) store the records displayed in c), in a user-specified filename
The next section provides information about the requirements for developing this program.
Task RequirementsA) Appendix A provides a sample input data from a file called messy.txt. It contains information meant to be stored in 4 classes: Point2D, Point3D, Line2D and Line3D. Please refer to the table in Appendix A for a description of the format in which the input data for each of the classes is stored.B) Note: You are to research and determine which kind of STL containers (e.g. Map, Vector, Set, Lists etc) you should use, to store all the various objects from the 4 classes. For this assignment you are not allowed to use array [ ] to store any of your data!C) Appendix B provides a description of the 4 classes: Point2D, Point3D, Line2D and Line3D, and the relationships between them. You are to study the diagrams and implement them accordingly.
D) Appendix C provides the sample output format and a description of the format requirements, for each of the 4 classes. These format are to be applied whether the data from these classes are output to a file or terminal.
E) Note2: To output data, you are required to create your own output manipulator(s) to display/store data in the format described in Appendix C. You are further required to overload the insertion operator <<, for each of the 4 classes, to support the process of inserting data to the terminal, or the relevant file stream.F) Note3: All output data must not contain any duplicates! There are many approaches to solving this problem. Firstly, you could check for, and remove duplicate records at the point of reading in the input. Alternatively, you could temporarily store the data in a STL container, research and make use of any STL algorithm to search for, and remove the duplicates. Another (inefficient) way is to store everything in STL container, but your program needs to ensure that when user wishes to see / store the records in a file, no duplicate records are shown.G) Appendix D provides a description of a few generic template functions that you are supposed to develop. These utility functions plays a supporting role, and they should be developed in a separate header file called MyTemplates.h.
H) Your program should allow user specify the filtering criteria so that user can specify which set of records he wishes to view / store. Your program should allow the following options:
i) Point2D records <= default selected option
ii) Point3D records
iii) Line2D records
iv) Line3D records
I) Your program should allow user to specify the sorting criteria so that user can specify which attributes (of a set of records) to order the data by. The sorting criteria is based on the current filtering criteria.
For example, if the current filtering criteria is Only Point2D records, your program should restrict user to the options of sorting the data by x, y & scalar value distFrOrigin only!
Please refer to Appendix E for a detailed description of the combinations of filtering criteria, and the respective (allowable) sorting criteria.
J) Hint: It is not necessary to develop your own sorting algorithm, or make use of any of the classical algorithms like Quick-Sort, Bubble-Sort to fulfill the sorting requirements. There is a function defined in STL algorithm (i.e. #include <algorithm) called sort. You should research on its usage, code the necessary comparator functions (for each of the 4 classes + sorting criteria). Once you mastered its usage, you will easily achieve the desired sorting effect using less than 3 lines of code!
K) To assist you in visualizing the desired program interactions, please refer to Appendix F which provides a sample menu displaying the output data / messages in response to user input.L) 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.M) 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 demo/evaluation during lab session. You must be prepared to perform certain tasks / answer any questions posed by the tutor.2) IMPT: Please follow closely, to the submission instructions in Appendix G, which contains details about what to submit, file naming conventions, when to submit, where to submit, etc.
3) 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) Program fulfills all the basic requirements stipulated by the assignment
(ii) Successful demonstration of a working program, clarity of presentation and satisfactory answers provided during Q & A session.
(iii) Additional effort (e.g. enhancing the program with relevant features over and above task requirements, impressive, killer presentation, etc)
(iv) 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.
APPENDIX A
(Sample messy data from an input file)
Point2D, [3, 2]
Line3D, [7, 12, 3], [-9, 13, 68]
Point3D, [1, 3, 8]
Line2D, [5, 7], [3, 8]
Point2D, [3, 2]
Line3D, [7, -12, 3], [9, 13, 68]
Point3D, [6, 9, 5]
Point2D, [3, 2]
Line3D, [70, -120, -3], [-29, 1, 268]
Line3D, [25, -69, -33], [-2, -41, 58]
Point3D, [6, 9, -50
Note:
1) Some data, (e.g. Point2D, [3, 2]) can be repeated multiple times (i.e. they are duplicated data), this applies to all other kinds of data as well.
2) In each line, the 1st field will contain the classs name (e.g. Point2D, Point3D, Line2D and Line3D)3) The delimiter separating the 1st field from the rest of the data, is a comma, followed by a space char (i.e. , )4) The delimiter separating each number in the 2D/3D coordinate, is also a comma, followed by a space char (i.e. , )
5) Each 2D/3D points data, is enclosed by the square brackets [ and ]
6) Each Line2D / Line3Ds data consists of two points, each enclosed by square brackets, and the delimiter separating each point is also a comma, followed by a space char (i.e. , )7) You may assume that the range of each number in the x, y or z coordinate can be anything from -999 to 999APPENDIX B
(The 4 classes, and their relationships)
APPENDIX B (cont)
Note:
1) The above diagrams depict the bare minimum requirements for the 4 classes whose attributes and methods you MUST implement
2) In Point2D class, setDistFrOrigin () method computes the distance of the point to the origin (0, 0), and initializes the attribute distFrOrigin with this distance value. The formula to compute is as follows:
distFrOrigin = (x 0)2 + (y 0)2 OR
distFrOrigin = x2 + y2
Note : means square root
3) In Point2D class, getScalarValue () method is merely an accessor method that returns the value of attribute distFrOrigin.
4) In Line2D class, setLength () method computes the distance between its own Point2D attributes pt1 and pt2, and initializes the attribute length with this distance value. The formula to compute is as follows:
length = (pt1.x pt2.x)2 + (pt1.y pt2.y)2
5) In Line2D class, getScalarValue () method is merely an accessor method that returns the value of attribute length.
6) In Line3D class, setLength () method computes the distance between its own Point3D attributes pt1 and pt2, and initializes the attribute length with this distance value. The formula to compute is as follows:
length = (pt1.x pt2.x)2 + (pt1.y pt2.y)2 + (pt1.z pt2.z)2
7) For all the 4 classes, you are free to declare and implement any additional attributes and methods like:
Overloading io-stream, arithmetic, comparison or any other operators <<, -, ==, etc.
Writing static comparator functions to use in STL algorithms and containers,
Writing io manipulators specific to a particular class
Writing any other supporting helper functions necessary to fulfill the requirements of this assignment.
APPENDIX C
(General Output Format for Point2D & Point3D data)
Note:
1) The allocated width to store each x, y and/or z ordinate value is 4 spaces, inclusive of minus sign
2) All x, y, z values are strictly whole numbers (i.e. integers) and all Dist. Fr Origin values are strictly decimal (i.e. double), with precision set at up to 3 decimal places
3) The 1st 2 lines (representing the header) is compulsory. The alignment of the X, Y or Z column names in the header is vertically aligned to its respective last digits position!
4) The should be 3 spaces between the end of each points data values, and its corresponding Dist. Fr Origin values
APPENDIX C (cont)
(General Output Format for Line2D & Line3D data)
Note:
5) In Line2D, the formatting for data under P1-X, P1-Y, P2-X and P2-Y headings is similar to that for Point2D. The corresponding formatting applies for the case of Line3D which is similar to that specified for Point3D.
6) The 1st 2 lines (representing the header) is compulsory. The alignment of the P1-X, P1-Y, P1-Z, P2-X, P2-Y and P2-Z column names in the header is vertically aligned to its respective last digits position!
7) The should be 3 spaces between the end of each points data values, and its corresponding Length values
APPENDIX D
(Description of Generic Function Template)
Template functionParameter descriptionIf param(s) is of the following Class / Type :Meaning of the template function when applied to (params) Class / TypeName : difference
Return Type :
TNo. of parameters : 2
Type of 1st parameter : T
Type of 2nd parameter : T
(i.e. you can deduce from above that BOTH parameters are of the same type T !)Numeric primitives (int, double, etc)parameter 1 parameter 2Point2DReturns a Point2D whose (x, y) values is the difference in the respective (x, y) values betw. parameters 1 and 2Point3DReturns a Point3D whose (x, y, z) values is the difference in the respective (x, y, z) values betw. parameters 1 and 2Line2DReturns a Line2D whose (pt1, pt2) object values is the difference in the respective (pt1, pt2) object values betw. parameters 1 and 2Line3DReturns a Line3D whose (pt1, pt2) object values is the difference in the respective (pt1, pt2) object values betw. parameters 1 and 2
Name : scalar_ difference
Return Type :
doubleNo. of parameters : 2
Type of 1st parameter : T
Type of 2nd parameter : TPoint2DThe absolute value difference in the scalar values betw. parameters 1 and 2.
(Hint: make use of the method getScalarValue() mentioned in Appendix B!)Point3DLine2DLine3D
APPENDIX D (cont)
(Description of Generic Function Template)
equals
Return Type :
boolNo. of parameters : 2
Type of 1st parameter : T
Type of 2nd parameter : TNumeric primitives (int, double, etc)parameter 1 == parameter 2Point2Dparam 1s x == param 2s x AND
param 1s y == param 2s yPoint3Dparam 1s x == param 2s x AND
param 1s y == param 2s y AND
param 1s z == param 2s zLine2Dparam 1s pt1 == param 2s pt1 AND
param 1s pt2 == param 2s pt2Line3D
Note:
1) Based on the information provided in the table, you will need to overload the relevant operators in the affected classes, in order to implement the meaning correctly, when the generic functions algo is applied on the 4 classes
2) The above generic function templates should be implemented in a header file called MyTemplates.h.
APPENDIX E
(Combinations of filtering + sorting criteria)
Filtering Criteria
Sorting Criteria (allow sorting by )
Point2D records
i) X ordinate value (default)
ii) Y ordinate value
iii) Dist. Fr Origin value
Point3D records
i) X ordinate value (default)
ii) Y ordinate value
iii) Z ordinate value
iv) Dist. Fr Origin value
Line2D records
i) X and Y coordinate values of Pt. 1 (default)
ii) X and Y coordinate values of Pt. 2
iii) Length value
Line3D records
Note:
1) Sorting by X and Y coordinates is done, by first ordering all rows according to x-ordinate value, this will have a sorting and bunching effect that groups rows with the same x-ordinate values together, if it exists.
Within each group with similar x-ordinate values, the sorting order (assuming it is ascending), is then applied to the y-ordinate, such that rows with the same X, but smaller Y value will be above those with same X, but bigger Y values.
2) For all sorting criteria, you should allow sorting in both ASCENDING and DESCENDING order! (Assume default is ASC).
3) If you are using STL containers / algorithms to handle the storage of your objects and sorting, you need to implement the relevant function comparators for each of the 4 classes. These function comparators should ideally be implemented as static boolean functions under each of the 4 classes.
APPENDIX F
(Sample Menu Interactions)
The figure on the left describes a sample interaction for specifying input filename to read in data.
The program should acknowledge by indicating the no. of records read in successfully!
The figure on the right describes a sample interaction for specifying filtering criteria to indicate which type of records user wish to see.
Note1: Observe that the current filtering criteria has changed in option 2) of the main menu, once it has been successfully set to Line3D !
Note2: Observe that the current sorting criteria is automatically changed to the default for Line3D records, which is sorting by Pt 1s (x, y) coordinates. (refer to Appendix E for details)
APPENDIX F (cont)
(Sample Menu Interactions)
The figure on the right describes a sample interaction for specifying sorting criteria to indicate which attribute, of the selected type of records user wish to see.
Note3: Observe that the sub-menu display options which are relevant to currently selected filter, which is Line3D! (refer to Appendix E for details)
Note4: Observe that the current sorting criteria has changed in option 3) of the main menu, once it has been successfully set to Length!
The figure on the right describes a sample interaction for specifying sorting order to indicate whether records are to be displayed / output in Ascending or Descending order.
Note5: Observe that the current sorting order has changed in option 4) of the main menu, once it has been successfully set to DSC!
APPENDIX F (cont)
(Sample Menu Interactions)
The figure on the right describes a sample interaction to display data.
Note6: Observe that all the latest criteria specified in main menu options 2) 4) are re-iterated before the rows of Line3D records are displayed.
The figure on the right describes a sample interaction to write data to an output file.
Note7: The contents and its formatting of the data in the output file Line3D.txt should be similar to that displayed when user choose main menu option 5! (please refer to output of the figure above)
APPENDIX G
Submission Instructions (V. IMPT!!)
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, *.o, or *.cpp files)
the executable file, compile into an executable file with *.exe
(e.g. Assn3.exe)
2) How to package
Compress all your assignment files into a single zip file. Please use the following naming format :
<FT/PT_Assn3_
Example : FT_Assn3_1234567_JohnDoeAnderson. zip
<FT/PT Use FT for Full-Time student, PT if you are Part-Time student
Assn3 if you are submitting assignment 3, Assn1 if submitting assignment 1 etc.
3) Where to submit
Please submit your assignment via Moodle eLearning site.
In the event of UNFORSEEN SITUATIONS :
( E.g. Students moodle account not ready, cannot login to moodle, eLearning site down on submission day, unable to upload assignment, etc )
Please email your single zip file to your tutor at :
[email protected] for FULL TIME students
[email protected] for PART TIME students
In your email subject line, type in the following information :
<FT/PT
Example:
To : tutors email (see above)
Subject : FT Assn3 1234567 JohnDoeAnderson
Note 1 : The timestamp shown on tutors email Inbox will be used to determine if the assignment is late or not.
Note 2 : After email submission, your mailboxs 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!
4) When to submit
a) 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.
b) Please refer to the following table on the different submission events and deadlines
AssignmentSubmission Deadline
(latest by 2300 hrs)Assignment Evaluation (Tasks), during Email Evaluation files by :
PTFT123 / 10 / 201626 / 10 / 2016Lab 2(PT), Lab 3(FT)End of Lab 2(PT), Lab 3(FT)201 / 11 / 201602 / 11 / 2016Lab 3(PT), Lab 4(FT)End of Lab 3(PT), Lab 4(FT)313 / 11 / 201615 / 11 / 2016Lab 4(PT), Lab 5(FT)End of Lab 4(PT), Lab 5(FT)
Note: (PT) = Part Time Students, (FT) = Full Time Students !
c) 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
d) 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
5) Please help by paying attention to the following
! VERY IMPORTANT !
PLEASE FOLLOW THE GUIDELINES IN ALL ASSIGNMENT APPENDICES !!
PLEASE FOLLOW THE SUBMISSION INSTRUCTIONS FROM 1 TO 4 !!
IF YOU ARE NOT SURE,
PLEASE CHECK WITH YOUR TUTOR DURING LABS / LECTURES !
OR PLEASE EMAIL YOUR ENQUIRIES TO YOUR TUTOR !
MARKS WILL BE DEDUCTED IF YOU FAIL TO FOLLOW INSTRUCTIONS !!Example : Your report document or zip file does not follow naming convention your email address does not include your name (i.e. cannot be used to identify sender) You have no email subjectWrong 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 submission cannot be downloaded and unzipped
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 tutor6) Re-submission administrationAfter 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:Zip up for re-submission files according to the following format :<FT/PT_Assn3_Resubmit_v1_ Example : FT _ Assn3_Resubmit_v1_1234567_JohnDoeAnderson. zip <FT/PT Use FT for Full-Time student, PT if you are Part-Time student assn3 if you are submitting assignment 3, Assn1 if submitting assignment 1 etc. Resubmit_v1 if this is your 1st re-submission Resubmit_v2 if this is your 2nd re-submission
V. IMPT To prevent Tutors Inbox from blowing up in his face, each student is only allowed to re-submit twice, for each assignment only!
Please email your single zip file to your tutors email (refer to section 3) Where to submit)
In your email subject line, type in the following information :
<FT/PT
Example:
To : tutors email (refer to section 3) Where to submit)
Reviews
There are no reviews yet.