Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

Background Information

This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fundamentals covered in the first half of the unit.

Assignment Requirements

You are required to design and implement two related programs:
• "admin.py", a CLI program that allows the user to manage the details of a collection of board games which are stored in a text file. Develop this program before "gamefinder.py".
• "game_finder.py", a GUI program that uses the data in the text file and allows the user to find games which match the criteria they specify. Develop this program after "admin.py".

The following pages describe the requirements of both programs in detail.

Starter files for both of these programs are provided along with this assignment brief, to help you get started and to facilitate an appropriate program structure. Please use the starter files.

Pseudocode
As emphasised by the case study of Module 5, it is important to take the time to properly design a solution before starting to write code. Hence, this assignment requires you to write and submit pseudocode of your program design for "admin.py", but not "game_finder.py" (pseudocode is not very well suited to illustrating the design of an event-driven GUI program). Furthermore, while your tutors are happy to provide help and feedback on your assignment work throughout the semester, they will expect you to be able to show your pseudocode and/or explain the design of your code.

You will gain a lot more benefit from pseudocode if you actually attempt it before trying to code your program - even if you just start with a rough draft to establish the overall program structure, and then revise and refine it as you work on the code. This back and forth cycle of designing and coding is completely normal and expected, particularly when you are new to programming. The requirements detailed on the following pages should give you a good idea of the structure of the program, allowing you to make a start on designing your solution in pseudocode.

See Reading 3.3 for further information and tips regarding writing good pseudocode.

Write a separate section of pseudocode for each function you define in your program so that the pseudocode for the main part of your program is not cluttered with function definitions. Ensure that the pseudocode for each of your functions clearly describes the parameters that the function receives and what the function returns back to the program.

It may help to think of the pseudocode of your program as the content of a book, and the pseudocode of functions as its appendices: It should be possible to read and understand a book without necessarily reading the appendices, however they are there for further reference if needed.

The three functions required in the "admin.py" program are detailed later in the assignment brief.

The following pages describe the requirements of both programs in detail.

Requirements of "admin.py"
"admin.py" is a program with a Command-Line Interface (CLI) like that of the programs we have created throughout the first half of the unit. It allows the user to manage the details of a collection of board games which are stored in a text file named "data.txt". The program (without optional additions and enhancements) can be implemented in under 150 lines of code - If your program significantly exceeds this, ask your tutor for advice. Everything you need to know in order to develop this program is covered in the first seven modules of the unit. This program should be developed before "game_finder.py".

This program allows the user to manage details of a collection of board games. The program will allow the user to add details of new games, as well as list, search, view and delete existing games.

A text file named "data.txt" will be used to store the details of games. Use the "json" module to write data to the text file in JSON format and to read the JSON data from the file back into Python. See Reading 7.1 for details regarding this.

Understanding the structure of this data and how you can use it is very important in many aspects of this assignment - in particular, you will need to understand how to loop through the items of a list and how to refer to items in a dictionary. Revise Module 3 and Module 7 if you are unsure about how to interact with lists and dictionaries.

In the following information, numbered points describe a requirement of the program, and bullet points (in italics) are additional details, notes and hints regarding the requirement. Ask your tutor if you do not understand the requirements or would like further information. The requirements are:

1. The first thing the program should do is try to open a file named "data.txt" in read mode, then load the data from the file into a variable named data and then close the file.
- The data in the file should be in JSON format, so you will need to use the "load()" function from the
"json" module to read the data into your program. See the previous page for details of the data.
- If any exceptions occur (e.g. due to the file not existing, or it not containing valid JSON data), then simply set the data variable to be an empty list. This will occur the first time the program is run, since the data file will not exist yet.
- This is the first and only time that the program should need to read anything from the file. After this point, the program uses the data variable, which is written to the file whenever a change is made.

2. The program should then print a welcome message and enter an endless loop which starts by printing a list of options: "Choose [a]dd, [l]ist, [s]earch, [v]iew, [d]elete or [q]uit." and then prompts the user to enter their choice. Once a choice has been entered, use an "if/elif" to respond appropriately (detailed in the following requirements).
- This requirement has been completed for you in the starter file.

3. If the user enters "a" (add), prompt them to enter the game name, then the minimum number of players, maximum number of players, average game duration and minimum player age. The details should then be appended to the data list and written to the text file in JSON format.
- Use your "inputSomething()" function (detailed below) when prompting for the name of the game, to ensure that the user is re-prompted until they enter something other than whitespace.
- Use your "inputInt()" function (detailed below) when prompting for the minimum players, maximum players, duration and minimum player age, to ensure that the user is re-prompted until they enter an integer.
- Once all the values have been entered, append the new game details to the data list (as a dictionary with same keys as shown on the previous page).
- Once the dictionary of game details has been appended to the data list, call your "saveData()" function (detailed below) to write the data to the text file.

4. If the user enters "l" (list), display a list of all games (just the name) preceded by their index number in the data list, or a "No Games Saved" error message if there is nothing in the list.
- Use a "for" loop to iterate through the games in the data list.
- You can use the "enumerate()" function to make sure you have a variable containing the index number of each game as you loop through them (see Lecture 3).

5. If the user enters "s" (search), prompt them for a search term and then list the games whose name contains what they type. Remember to include the index number next to each game.
- If the data list is empty, show a "No Games Saved" message instead of prompting the user for a search term.
- This is a good opportunity to reuse and tweak the code to list all games - the loop body needs an "if" to only print game names that contain the search term (use the "in" operator - see Lecture 3).
- Convert the search term and game name to lowercase to find matches regardless of case.
- Use your "inputSomething()" function (detailed below) when prompting for the search term, to ensure that the user is re-prompted until they enter something other than whitespace.

6. If the user enters "v" (view), prompt them for an index number and then print the corresponding game's name and other details as shown in the example screenshots below.
- If the data list is empty, show a "No Games Saved" message instead of prompting the user for an index number.
- Use your "inputInt()" function (detailed below) to prompt the user for the index number of the game, to ensure that the user is re-prompted until they enter an integer.
- Display an "Invalid Index Number" message if the user enters an index number that doesn't exist in the data list.

7. If the user enters "d" (delete), prompt them for an index number and then delete the corresponding item from the data list, then display a "Game Deleted" message.
- If the data list is empty, show a "No Games Saved" message instead of prompting the user for an index number.
- Use your "inputInt()" function (detailed below) to prompt the user for the index number of the game, to ensure that the user is re-prompted until they enter an integer.
- Display an "Invalid Index Number" message if the user enters an index number that doesn't exist in the data list.
- Once the game has been deleted from data list, call your "saveData()" function (detailed below)
to write the data to the text file.

8. If the user enters "q" (quit), print "Goodbye!" and break out of the loop to end the program.

9. If the user enters anything else, print an "Invalid Choice" message (the user will then be re- prompted on the next iteration of the loop).

This concludes the core requirements of "admin.py". The following pages detail the function mentioned above, the additional requirements for CSP5110 students, optional additions and enhancements, and an annotated screenshot of the program.

Remember that you are required to submit pseudocode for your design of "admin.py".

Functions in "admin.py"
The requirements above mentioned three functions - "inputInt()", "inputSomething()", and "saveData()". As part of "admin.py", you must define and use these functions.

1. The "inputInt()" function takes one parameter named prompt. The function should repeatedly re-prompt the user (using the prompt parameter) for input until they enter an integer. It should then return the value as an integer.
- See Workshop 4 for instructions regarding a similar function.

2. The "inputSomething()" function takes one parameter named prompt. The function should repeatedly re-prompt the user (using the prompt parameter) for input until they enter a value which consists of at least one non-whitespace character (i.e. the input cannot be nothing or consist entirely of spaces, tabs, etc.). It should then return the value as a string.
- Use the "strip()" method on a string to remove whitespace from the start and end. If a string consists entirely of whitespace, it will have nothing left once you strip the whitespace away.
- Note that exception handling is not needed in this function.

3. The "saveData()" function takes one parameter named dataList (this will be the data list). The function should open "data.txt" in write mode, then write the dataList parameter to the file in JSON format and close the file. This function does not return anything.
- This is the only part of the program that should be writing to the file, and it always simply overwrites the entire content of the file with the entirety of the current data.
- See Reading 7.1 for an example of using the "json" module. You can specify an additional indent
parameter in the "dump()" function to format the JSON data nicely in the text file.

The definitions of these functions should be at the start of the program (as they are in the starter file provided), and it should be called where needed in the program. Revise Module 4 if you are uncertain about defining and using functions, and be sure to implement them so that they receive and return values exactly as described above. In particular, remember that the "prompt" parameter of inputInt() and inputSomething()is for the text that you want to show as a prompt.

You are welcome to write additional functions if you feel they improve your program.

Additional "admin.py" Requirements
If you are in CSP5110, the following additional requirements apply. If you are in CSP1150, you do not need to do implement these requirements (but you are encouraged to do so if you want). Ask your tutor if you do not understand any of the requirements or would like further information.

1. Add 1 to the index number of games whenever the list or search results are shown, so that the list begins at 1 instead of 0. Remember to subtract 1 from the user's input when viewing or deleting games so that you reference the appropriate index of the data list.

2. As well as ensuring that the user enters an integer, the "inputInt()" function must also make sure that the integer is larger than 0 (i.e. a minimum of 1). Make sure that this requirement is mentioned in the error message that is displayed if an invalid value is entered.

Optional Additions and Enhancements for "admin.py"
The following are suggestions for optional additions and enhancements that you can implement to demonstrate deeper understanding of programming and deliver a product which is more "polished". They are not required, but you are encouraged to implement them (and others) if you can.

- When searching the games, show a "No results found" message if the search term is not found in any of the games in the data list.
o Be sure to only show this message once per search, not once for every game.

- Add some code to the "add" section that checks if there is already a game in the data list with the same name after the user enters the name of the game. If there is, alert the user to this fact (and the index number of the existing game) and discontinue adding the new game.
o You could also use a loop to re-prompt them until they enter a different name.

- Add a new menu option of "[b]reakdown" which calculates and shows:
o The number of games in the data list.
o The minimum number of players across all games in the data list.
o The maximum number of players across all games in the data list.
o The average duration of the games in the data list.
o The average minimum age of the games in the data list.

- Allow users to use the search, view and delete options more efficiently by allowing input of "s ", "v " and "d ". For example, instead of needing to type "s" and then "catan", the user could type "s catan", and instead of needing to type "v" then "1", the user could type "v 1".
o This feature takes a relatively large amount of extra thought, code and effort.

Details of "game_finder.py"
"game_finder.py" is a program with a Graphical User Interface (GUI), as covered in Module 9. The entirety of this program can be implemented in under 150 lines of code - If your program exceeds this, ask your tutor for advice. This program should be developed after "admin.py". To ensure compatibility and consistency, you must use the "tkinter" module to create the GUI. You will also need to use the "tkinter.messagebox", and "json" modules.

The program allows the user to find games which match the criteria they specify, using data from the "data.txt" file. The program should load all of the data from the file once only - when the program begins.

Constructor of the GUI Class of "game_finder.py"
The constructor (the " init " method) of your GUI class must implement the following:

1. Create the main window of the program and give it a title of "Game Finder".
- You may also wish to set other settings such as the minimum size of the window.

2. Try to open the "data.txt" file in read mode and load the JSON data from the file into an attribute named "self.data", and then close the file.
- If any exceptions occur (due to the file not existing, or it not containing valid JSON data), show an
error messagebox with a "Missing/Invalid file" message and use the "destroy()" method on the main window to end the program. Include a "return" statement in the exception handler after destroying the main window to halt the constructor so that the program ends cleanly.

3. The constructor should then use Label, Entry, Button and Frame widgets from the "tkinter" module as needed to implement the GUI depicted on the previous page.
- You will save time if you design the GUI and determine exactly which widgets you will need and how to lay them out before you start writing the code.
- You are welcome change the layout of the GUI, as long as the functionality is implemented.
- See Reading 9.1 for information regarding various settings that can be applied to widgets to make them appear with the desired padding, colour, size, etc.
- The Button that allows users to submit the form should call the "findGames()" method (detailed below) when clicked. You will need to refer to it as "self.findGames".
- Since no games will be listed under the "Matching Games" heading when the program first loads, make sure that there is initially a label showing a message such as "No criteria submitted."

4. Finally, the constructor should end by setting the initial focus of the program to the number of players Entry widget, and then calling "tkinter.mainloop()" to start the main loop of the program's GUI.

That is all that the constructor requires. The following page detail the "findGames()" method, the additional requirements for CSP5110 students and optional additions and enhancements. You are not required to submit pseudocode for your design of "game_finder.py", as pseudocode is not particularly well suited to illustrating the design of an event-driven GUI program.

The "findGames()" Method of the GUI Class of "game_finder.py"
Your GUI class only requires one method to implement the functionality of the program - "findGames()". It does not require any parameters other than "self", which is passed to all methods in a class. The "findGames()" method is called when the user clicks the submit button, and it must do the following:

1. Get the values that the user has typed into the Entry widgets for number of players, time available and age of youngest player, and convert them to integers. If an exception occurs when converting any of the values to an integer, display a messagebox saying "Invalid criteria specified" and do nothing else.
- Use the "get()" method on the Entry widget to retrieve its current value.

2. If no exceptions occurred and all three values were able to be converted to integers, loop through the self.data list and identify any games which match the criteria. Display the names of matching games below the "Matching Games" heading.
- Make sure that you get rid of any message or previous list of game names that may already be there.
- To match the criteria, the number of players must be between the minimum and maximum number of players, the duration must be less than or equal to the time available, and the minimum age must be less than or equal to the age of the youngest player.
- An "else" can go after "except" and will only run if no exception occurred. See end of Lecture 6.

3. If no matching games are found, display a "No matching games" message below the "Matching Games" heading.
- You may wish to create a "noMatches" variable and set it to True before looping through the games, and then set it to False when a game matching the criteria is found. Show the message if the variable is still set to True after the loop.

Additional "game_finder.py" Requirements
If you are in CSP5110, the following additional requirements apply. If you are in CSP1150, you do not need to do implement these requirements (but you are encouraged to do so if you want). Ask your tutor if you do not understand any of the requirements or would like further information.

1. The layout and presentation of your GUI will be assessed more critically. Make appropriate use of frames, alignment, fill/expand and padding settings to create a clear and consistent layout. Use font colour, size or styles to make important text stand out.

2. When showing the results of a search, the program should display the number of matching games and the total number of games, e.g. "3 out of 14 games matched the search."

Optional Additions and Enhancements for "game_finder.py"
The following are suggestions for optional additions and enhancements that you can implement to demonstrate deeper understanding of programming and deliver a product which is more "polished". They are not required, but you are encouraged to implement them (and others) if you can.

- Give the program a custom icon and add a suitable background image to the main window.

- Add a second Button next to the Submit button labelled "Choose For Me". When this button is clicked, matching games are found as normal, but instead of showing the names of all matching games, just one of them is randomly selected to be shown.

Attachment:- Assignment.rar

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M93136261
  • Price:- $90

Guranteed 48 Hours Delivery, In Price:- $90

Have any Question? 


Related Questions in Programming Language

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

Assignment - haskell program for regular expression

Assignment - Haskell Program for Regular Expression Matching Your assignment is to modify the slowgrep.hs Haskell program presented in class and the online notes, according to the instructions below. You may carry out th ...

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

Task arrays and structsoverviewin this task you will

Task: Arrays and Structs Overview In this task you will continue to work on the knight database to help Camelot keep track of all of their knights. We can now add a kingdom struct to help work with and manage all of the ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As