SIT102 Introduction to Programming
编程代做 When you run the program, you should see a menu to manage your kingdom (addknights, select knights, delete knights, etc)
Pass Task 7.1P – Arrays and Structs
1.Introduction
In this task you will continue to work on the Task 5.1P knight database to help Camelot keep track ofall of their knights. We can now add a kingdom struct to help work with and manage all of theknights in the kingdom.
Note:
This is the last code writing Pass task, and as such you should try to complete theprevious code writing tasks before attempting this.
Submission Details 编程代做
Use the instructions on the following pages to create a small program that explores a more complex useof arrays and data structures.
Submit the following files to OnTrack:
1.A PDF of your Answers to the guestions available in the Task Resources: answer these in vourown words and provide a Harvard reference for any online source that you take knowledge fromfor this task.
2.A screen shot of your program running on your computer: this should be a full screen screenshot that shows your entire screen with the program.
3.Arrays and Structs source code: this is the program.cpp file that you create as part of the taskinstructions
The focus of this task is on the tools and approaches to working with more complex data using structsand dynamic arravs, with matching functions and procedures to help ease the coding efforts.
2. Getting Started 编程代做
Note:
To complete this task, you will need to have completed the earlier tasks 5.1P, 6.1Pand 6.2P to have the knowledge (and code) to go further.
To get started:
Watch this task’s video on updating the Kingdom Database code with additional types anddynamic arrays, and make the changes shown there. A link to the video is provided below:https://moodle.deakincollege.edu.au/mod/hvp/view.php?id=543472
Changes from the video include:
- A kingdom struct with a vector of knights
- An add knight procedure to add a knight into the Kingdom
- A write kingdom procedure to output the details of the Kingdom and its knights
- A delete knight procedure to delete a knight from the kingdom
This is a lot of code, so double check everything so far before moving on. Your program at this pointshould compile – if it does not and you get errors, talk to your teacher and get some advice in class ifyou cannot fix the errors yourself.
3. Your Task Requirements 编程代做
To finish off this task you now need to extend this program further and then answer thequestions in the Task Resources document.
Extending This Program – a larger kingdom…
We want to be able to select individual knights in the kingdom to see their details, as well as to addfollowers to each knight (these followers can just be strings in our code e.g. “Squire”). We also wantthis program controlled using a text menu where the user can choose to add, delete, and queryknights to better manage the kingdom.
1.Add a select knight function.
- Implement the function as:
This function will return the index of a knight in the array.
- lt will show the user a list of all of the knights (with index numbers next to them)
- The user is then asked to select a knight by entering their index
- The prompt should loop until the user selects a valid option.
- The function then returns the value the user entered. So selecting the first knightwill be index 0, the second knight is index 1, and so on.
2.Create a new update kingdom procedure which shows a new menu (using enum,procedures, and functions) to allow the user to choose between the different systemactions: adding knights, deleting knights, update knights, and displaying details:
- Adding will call the add knight procedure you made in step 1
- Deleting will need to use the new delete knight procedure, but you will first need t0call select knight and let the user choose the knight to remove
- Query will cause the program to call the query knight procedure described further0below in step 4 of these instructions.
- Displaying details will show the kingdom data by calling the write kingdomoprocedure.
3.Add followers to each knight.
- Add a dynamic array of strings called followers (vector<string> followers;) to the0knight struct.
- Change update knight to include the option to add a follower (note: you need to0add this as an option in the menu). When this is selected from the menu, have theuser enter the type of follower (e.g. “squire”, “jester”, apprentice”) and add this tothe knight’s current followers. 编程代做
- Change write knight to also output the number of followers the knight has.
4.Add a query knight option to the main menu created in step 2. This will allow the user to4output the details of a single knight.
- lmplement void query knight(const kingdom data &kingdom) as a new procedure
- Select a knight to query – Do you have a function for this already?
- Use write knight to display their details
- Then list all of their followers with an appropriate header (e.g. “This knight if
followed by: “); - Confirm that all of the features in this now much larger kingdom program is working.
Answering the Questions
Download the Task Resources from OnTrack, You will find the button to download these in the TaskDetails page, as shown below.
1.Unzip the file, which in this case will contain a Microsoft Word document template for youranswers.
2.Open the Word document and answer the questions inside. You will want to use theseguestions as vour chance to demonstrate that you have fully understood the actions youperformed in this task.
3.When finished, save your work, and keep a copy for yourself, You may need to fix incorrect3answers and resubmit if your teacher finds a problem.
Lastly, export a copy of the document to PDF. You can use Word’s Save As feature to save to a PDFformat. The PDF document is what you submit to OnTrack with your code.
Submit your work 编程代做
Do the following before you submit:
- Check to make sure you have your kingdom correctly managing your knights and theirfollowers. When you run the program, you should see a menu to manage your kingdom (addknights, select knights, delete knights, etc) and when choosing to update a knight, youshould see a second menu screen (update name, update age, etc).
- Download the Task resources and answered the questions in the Word file. Save the file asPDF to prepare for upload.
When you are ready, login to OnTrack and go back to Task 7.1P and submit your program code,program screenshot, and answers to the questions.
Remember to save and backup your work!