Monash College


MCD4720 - Fundamentals of C++

Assignment 1 - Trimester 1, 2021


Submission guidelines

This is an individual assignment, group work is not permitted

Deadline: March 23, 2021, 11:55pm

Weighting: 10% of your final mark for the unit


Late submission:

By submitting a Special Consideration Form or visit this link: https://lms.monashcollege.edu.au/course/view.php?id=1331

Or, without special consideration, you lose 5 marks of your mark per day that you submit late (including weekends). Submissions will not be accepted more than 5 days late. This means that if you got Y marks, only Y-n*5 will be counted where n is the number of days you submit late.

Assessment items will not be accepted after more than 14 calendar days unless a Special Consideration application has been approved. This 14-day time frame does not apply to assessments due in Week 12.

Marks: This assignment will be marked out of 100 points, and count for 10% of your total unit marks.

Plagiarism: It is an academic requirement that the work you submit be original. If there is any evidence of copying (including from online sources without proper attribution), collaboration, pasting from websites or textbooks, Zero marks may be awarded for the whole assignment, the unit or you may be suspended or excluded from your course. Monash Colleges policies on plagiarism, collusion, and cheating are available here or see this link: https://www.monashcollege.edu.au/__data/assets/pdf_file/0010/17101/dip-assessment-policy.pdf Further Note: When you are asked to use Internet resources to answer a question, this does not mean copy-pasting text from websites. Write answers in your own words such that your understanding of the answer is evident. Acknowledge any sources by citing them.


Submission Instructions:

Your project must be submitted as a Visual Studio project, including all header and code files, and any appropriate text files to ensure the program compiles and runs.

You may complete the tasks in your preferred IDE, however you MUST create a Visual Studio project in order to submit. Your project folder must be identified by using your name and assignment number, such as YourNameA1.

The entire project folder must then be zipped up into one zip file for submission. The zipped file MUST be named YourFistNameLastName_A1.zip”. This zip file must be submitted via the Moodle assignment submission page.

Explicit assessment criteria are provided, however please note you will also be assessed on the following broad criteria:

Meeting functional requirements as described in the exercise description.

Demonstrating a solid understanding of object-oriented design and C++ coding, including good practice.

Following the unit Programming Style Guide.

Creating solutions that are as efficient and extensible as possible.Monash College


NOTE! Your submitted program MUST compile and run. Any submission that does not compile will automatically awarded a 50 marks penalty. This means it is your responsibility to continually compile and test your code as you build it.

NOTE! Your submitted files must be correctly identified and submitted (as described above). Any submission that does not comply will receive and automatic 20 marks penalty (applied after marking). Your Visual Studio project should include all .cpp, .h and .txt files.

NOTE! Your tutor may ask you to program part of your assignment in class to determine that you have completed the work yourself. Failure to do this to an acceptable level will result in you being referred to the Subject Leader for plagiarism.


Scenario:

You have just joined a new multimedia company called CyberRoo. As a new employee, you have been tasked with creating a text-based prototype for a new game tool the company has been asked to create by a major client called The Amazing RPG Character Generator”.

Your job is to demonstrate some of the basic functionality of the program, which will be further developed by the team of programmers after your finish the prototype. To do this you will complete a series of tasks, each building upon the previous task.


Task List:

 Your project must include an application file – correctly formatted including variable and function declarations.

 Create and display a menu that accesses each of the following functions of the program.

 Read data from a file and display it as an information screen about the application.

 Read some sample data from a file and store it appropriately.

 Generate a random RPG character and display the result using the stored data.

 Save a character to file, appending each new character saved, at the user’s request.

 Load all saved characters from the saved file and display the contents.


Task 1: Create and Display a Menu

Your first task is to create and display a menu, just like the one shown here. In the example, option [1] has been selected, terminating the program.

Create a function called runMenu() and call it from the main() function.

From this function, the user must be able to select any of the displayed options as often as they want before ending the program.

Ensure that you validate the user’s input so that only the options displayed can be chosen.Monash College


Task 2: Display an Information Screen

Your next task is to display some information about the application, just like the one shown here.

Create a function called displayText() and call it from the runMenu() function, when option [2] Display “About” Information is selected.

This function must accept a filename as a parameter (“MadAbout.txt”) then read and display the data.

You must allow the user some time to read the displayed information before returning them to the menu.

You can copy MadAbout.txt into the appropriate folder to read and display, instead of creating your own. However, you may need to modify the format of the data, depending on how you intend to import it into your program.

You may create your own information, if you wish. If you do, keep it short!


Task 3: Read and Store Data from a File

Your next task is to read and store the Mad Lib data, from one (or more) text files, and store this data in appropriate variables. This data will be used to generate the randomised Mad Libs in the next task.

Create a function called createLists() and call it from the runMenu() function, when option [3] Read and Store Data from File is selected.

This function must accept a filename as a parameter (“*.txt”) and successfully read and store the data. The data is to be stored in two collection variables named madLibs, and madBits.

You can choose to read the data from a single file, storing each data set in the different variables, OR read and store each data set with two separate calls to the same function with different arguments OR use another suitable method of your own devising.

You may also be required to manipulate the string data, using appropriate string methods.

The data for the two individual collections can be found in madBits.txt and madLib.txt (provided on Moodle), which you can modify or change to suit your method of reading and storing the data, instead of writing your own. You are free to write your own data, if you wish. Remember to name and store your text files appropriately.

The data for the mad bits is currently written so that it identifies the types of words the user must input for its matching Mad Lib. The Mad Libs themselves have place holders for each word, which will be replaced by the user’s input.

WORD was WORD the WORD for their latest WORD.

a NAME, a VERB ending in ING, a plural NOUN, a NOUN


BoTask 4: Generate and Display a Random Mad Lib

Your next task is generating a random Mad Lib, using 3 different elements from the mad libs collection, and ask the user to input appropriate words, using the associated mad bits and display the result as a concatenated or formatted string.

Add a function generateMadLib() and call it from runMenu() function, when option [4] Generate a Random Mad Lib is selected.

This function must return a formatted or concatenated string using 3 randomly selected Mad Libs. The user is asked to type in words of the specific type, using the matching mad bits data for each selected Mad Lib.

You will need to use a number of string manipulation techniques to achieve the desired result. Think through the process carefully before you start to write your code. Hint: work it out using pen and paper first using one Mad Lib.

Ensure that the collection variables have content in them before trying to select an element, to stop the program from crashing.

See screen shot for an example of the required output.


Task 5: Save a Mad Lib to a File

Your next task is to save a Mad Lib to a file, called savedMadLibs.txt”.

In this task you must:

display the last generated Mad Lib

ask the user if they want to save it

if so, add it to any existing data in the file

if not, do nothing

return to the menu when the task is complete

Create a function called saveData() and call it from the runMenu() function, when option [5] Save a Mad Libs to file is selected.

Use the screen shot as a guide for your display and input request. You should also inform the user when the data is saved, before returning to the menu.



Task 6: Load Saved Mad Libs from a File

Your final task is loading the saved Mad Libs from the savedMadLibs.txt” and displaying them appropriately.

How you achieve this is dependent upon how you saved the data. Ideally, the display should be the same as the way you displayed the Mad Lib when you generated it.

Use the screen shot as a guide for your display – these Mad Libs are being displayed in the same way as they were originally generated.

Things you may need to consider:

Do the collection lists need to be initialised before you display the saved data?

How have you saved the data?

Did you save the random numbers for each element type?

Did you save the completed strings?

Did you use another method?

How will you display the data after it is read from the saved data file?

▪ Which method is the most efficient way to display it?

How will you ensure that the user has time to read the output before returning to the menu?


Assignment Notes:

It is your responsibility to know what is expected of you. If you are unsure about anything, ask your tutor sooner rather than later. Write any questions and/or notes here to help you clarify what you have to do.

Assignment 1: Marking Criteria [100 marks in total]

NOTE: Your submitted project must be correctly identified and submitted, otherwise it will receive an automatic 20 marks penalty (applied after marking).

Does the program compile and run? Yes or No

NOTE! Your submitted program MUST compile and run. Any submission that does not compile will receive an automatic 50 marks penalty (applied after marking).

1. Application Design [20]

1.1. Application File [20]

1.1.1.The main() function has appropriate function calls to keep it uncluttered [4]

1.1.2.Has all the correct #include statements [4]

1.1.3.Has the required data members and member functions using meaningful names [4]

1.1.4.Has created all function prototypes correctly [4]

1.1.5.Has created any additional functions to streamline their code [4]


2. Functionality [60]

2.1. Task 1: Menu [12]

2.1.1. The runMenu() function correctly initialises any required variables [2]

2.1.2. The menu options are clearly displayed [2]

2.1.3. Appropriate use of loop and decision structures to process user input [2]

2.1.4. Correct use of function calls when responding to user input [2]

2.1.5. The user controls when to return to the menu [2]

2.1.6. Appropriate exit [2]

2.2. Task 2: About Information [8]

2.2.1. The displayText() function uses the correct argument [2]

2.2.2. Appropriate validation checks have been made [2]

2.2.3. Appropriate use of loop and decision structures to read and display data [4]

2.3. Task 3: Reading and Storing Data [10]

2.3.1. The createLists() function uses the correct argument [2]

2.3.2. The collection variables (arrays or vectors) are correctly initialised [2]

2.3.3. Appropriate method(s) used to read the data from the file [2]

2.3.4. Appropriate use of loop and decision structures to read and store data [4]

2.4. Task 4: Generate and Display a Storyline [8]

2.4.1. The generateMadLib() function returns a string [2]

2.4.2. Validation checks that collection lists have been created [2]

2.4.3. One random data element is selected from each collection [2]

2.4.4. The returned string is correctly concatenated and/or formatted [2]

2.5. Task 5: Save Data to a File [12]

2.5.1. The saveData() function uses the correct argument(s) [4]

2.5.2. The current story line data is displayed appropriately [2]

2.5.3. The user is asked whether to save or not with an appropriate process of user input [2]

2.5.4. Appropriate validation for writing the file is in place [2]

2.5.5. The data is correctly written to the specified file [2]

2.6. Task 6: Load Data from a File [10]

2.6.1. The loadData() function uses the correct argument(s) [2]

2.6.2. Appropriate validation checks, loop and decision structures to read and display data [4]

2.6.3. Generated data is displayed using correct formatting after loading [4]


3. Quality of Solution and Code [20]

3.1. Does the program perform the functionality in an efficient and extensible manner? [4]

3.2. Has a well-designed program been implemented? [8]

3.2.1. Appropriate additional functions created to streamline code [4]

3.2.2. Demonstrates the use of logical procedures [4]

3.3. Has the Programming Style Guide been followed appropriately? [8]

3.3.1. All functions and variables have meaningful names and use correct camel notation [4]

3.3.2. Appropriate use of comments throughout the code [4]