0% found this document useful (0 votes)
32 views2 pages

A3 Report

The document describes a C++ program that allows a user to input records of 2D and 3D points and lines, filter the records by class, sort them, display them, and write them to a file. It discusses the classes and structs used to store point and line data, and the functions implemented for input, sorting, filtering and output. The program uses operator overloading, generic programming, and other C++ features.

Uploaded by

EvenBetterX
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views2 pages

A3 Report

The document describes a C++ program that allows a user to input records of 2D and 3D points and lines, filter the records by class, sort them, display them, and write them to a file. It discusses the classes and structs used to store point and line data, and the functions implemented for input, sorting, filtering and output. The program uses operator overloading, generic programming, and other C++ features.

Uploaded by

EvenBetterX
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Name : Goh Wee Kiat Brendan

UOW ID : 7433098
Tutorial Group : T06F

Assignment 3 Report

1. Interpreted program requirements:

The program will receive user input (a choice from 1 - 7). 1 for record entry, 2 to filter which of
the 4 classes of objects to show (point 2d,3d and line 2d,3d), 3 to set sorting options based on
the object class, 4 to set if sorting is done in increasing or decreasing order, 5 to display existing
records, 6 to write to a file and 7 to quit. Operator overriding should be used to improve
meaning throughout the program and generic programming should be used to reduce the
overall lines of code.

2. Program design:
Class relations
3. Summary of function implementation:
Classes and structs:

Point2D stores 2 integers, its x and y coordinates.pointToString is used to convert the


coordinates to a formatted string
Operators are overridden to enable calculation of scalar differences, and to enable the use
of << to extract all the information of the object.
As vectors are used to store data, there are comparators to sort the information.

Point3D inherits data from Point2D, and stores an additional variable, its z coordinate.

Line2D contains 2 2D points. Operators are overridden to enable calculation of scalar


differences, and to enable the use of << to extract all the information of the object.
As vectors are used to store data, there are comparators to sort the information.

Line3D inherits data from Line2D, but it stores 2 3D points instead of 2D.

The Records struct stores 4 vectors, each of the previously mentioned classes. It also
contains a function to sort the vectors based on a user input and one to output the filtered
vector into a stream.

Main program:

The user is prompted to enter an option, then they will be taken to a submenu based on the
interpreted program requirements.

The *inString functions are used to convert the user options (eg. a, b, c) into strings for
display purposes.

After each option change, the records are sorted as the records have to be sorted upon both
display and output.

pressEnterToReturn() is used to pause the display till the user presses enter.

4. Reflection:
Through this assignment, I’ve improved my knowledge of c++ along with reinforcing the
things learned through the previous assignment. Some new things used here are operator
overloading as well as generic programming. I also spent some time to explore using “auto”
as well.

You might also like