Navigation Menu
Search code, repositories, users, issues, pull requests..., provide feedback.
We read every piece of feedback, and take your input very seriously.
Saved searches
Use saved searches to filter your results more quickly.
To see all available qualifiers, see our documentation .
- Notifications You must be signed in to change notification settings
Answer key for APCSA Edhesive 2020 - learn from example, don't plagiarize.
Jovakan/apcsa2020
Folders and files, repository files navigation, ap computer science a 2020 (edhesive).
This repository is organized into the units and lessons inside them. You will also find the assignments but you will find no answers to any of the reviews, quizzes, or exams. Labs assigned by the College Board do NOT follow the uniform formatting and their directory is named after the actual name for ease of search outside of Edhesive users.
I will update this after my class is finished with one lesson. If you have any questions, comments, or additions, feel free to contact my Discord. Good luck!
Path format: [Unit#]/[Lesson#]/[Unit#][Lesson#][Question#].java
Unit 1: Primitive Types
Lessons 1-6
Assignment 1: Movie Ratings
Unit 2: Using Objects
Lessons 1-8
Assignment 2: Control Tower
Unit 3: Boolean Expressions and If Statements
Lessons 1-7
Assignment 3: Crack the Code!
Unit 4: Iteration
Assignment 4: String Shortener
Lab: Consumer Review
Unit 5: Writing Classes
Lessons 1-9
Assignment 5: Fraction
Unit 6: Array
Lessons 1-5
Assignment 6: Array Statistics
Unit 7: ArrayList
Assignment 7: Game Wheel
Lab: Data Lab
Unit 8: 2-D Arrays
Lessons 1-2
Assignment 8: Battleship
Lab: Steganography
Unit 9: Inheritance
Lessons 1-3
Assignment 9: Ultimate Frisbee
Lab: Celebrity
Unit 10: Recursion
Lessons 1-4
Assignment 10: Anagrams
Contributors 3
- Java 100.0%
- For educators
- English (US)
- English (India)
- English (UK)
- Greek Alphabet
This problem has been solved!
You'll get a detailed solution from a subject matter expert that helps you learn core concepts.
Question: Assignment 7: Game Wheel Instructions For this assignment, you will work on a multi-file program which represents a game using a spinnable Game Wheel, a bit like the one seen on the show Wheel Of Fortune (below). Your Game Wheel will have 20 evenly cut colored “slices”, each marked with a cash prize amount. Two classes are used to create this wheel:
Assignment 7: Game Wheel
Instructions
For this assignment, you will work on a multi-file program which represents a game using a spinnable Game Wheel, a bit like the one seen on the show Wheel Of Fortune (below).
Your Game Wheel will have 20 evenly cut colored “slices”, each marked with a cash prize amount. Two classes are used to create this wheel: GameWheel and Slice. You will not need to edit the Slice class, but you will implement some of the methods for the GameWheel class. You will also write a method in a third class named Game which can be used to play the game.
As this assignment uses pre-written methods which you will need to use in your code, brief documentation of the constructors and public methods of the GameWheel and Slice classes is included at the end of the assignment brief.
Part 1: GameWheel
When a new GameWheel is created it always contains 20 slices, which are represented in the GameWheel class by an ArrayList of Slice objects. The wheel is initialized so that every slice with an odd index is red and every slice with an even index is blue, with the exception of the slices at positions 0, 5, 10 and 15 which are all black. Every slice is initialized with a different prize value.
You will implement three different public methods in the GameWheel class.
The first of these methods is the toString method, which returns a String consisting of a numbered list of all slices of GameWheel (using the slice toString method), one on each line. This should be in the format shown below:
You may find the toString method helpful when testing your other GameWheel methods.
The second method you will write is the scramble method, which randomizes the positions of the slices that are in the wheel, but without changing the pattern of the colors (i.e. the black slices will still be at multiples of 5, the red slices at all other odd indices and the blue slices at all other even indices). No individual slice should be changed, rather the slices should be re-ordered.
The third method to implement is the sort method. This is similar to the scramble method in that it reorders the slices in the GameWheel so that the pattern of the colors remains the same. After the sort method is called however the slices of each color should be sorted in increasing order of prize amount. So for example the black slice with the lowest prize value will be at index 0, and the black slice with the highest prize value will be at index 15.
Part 2: Game/play
When you have done the above, you will write a method in the Game class named play. This method has a single GameWheel parameter. When run, this method will simulate a game in which the game wheel represented by this parameter is spun three times and the results are used to calculate a total prize. The total prize is found by adding the values on the three slices. If all three slices are the same color, then this sum should be doubled (and an additional line should be printed at the end explaining this). For the exact format of the output of the program, see the sample runs below (as this program involves some randomization the actual output will vary).
Sample run 1
Sample run 2
Testing your code
The fourth class named Runner has a pre-written main method which will let you test your code. You can choose to play the game by calling the play method from your game class or test individual methods from the GameWheel class. Please do not write a main method in any of the other classes as these will stop your code from being scored correctly.
Documentation
As you work on this assignment, you can use the milestones below to inform your development process:
Milestone 1: Set up the toString method for the gameWheel class so you can test your methods as you write them. Plan how you will decompose the scramble and sort methods (i.e. are there helper methods which can be used by both).
Milestone 2: Write the scramble and sort methods in the gameWheel class. Use the runner class and the toString methods to test these methods work exactly as intended.
Milestone 3: Implement the play method in the game class. Make sure you run this multiple times to ensure it works under a variety of conditions.
Decomposition hints
More than any exercise or assignment you've seen so far, this assignment requires you to carefully decompose what needs to be done into steps. This is especially true when implementing the scramble and sort methods. There is no one right way to do this, and very different approaches can still end up working. Below are some hints which might help you get started, but do feel free to experiment and come up with your own way
- One way to implement the scramble and sort methods might be to split the slices list up into separate lists by color, then put them back together into the slices list once they are scrambled/sorted.
- You could sort/scramble these separate lists, or be even smarter and sort/scramble them either as you put them into the list or as you put them back into slices.
- Because there is a lot of repetition in these methods you should think about writing helper methods that prevent you from having to write code which is almost the same several times.
- Examples of where helper methods could be useful include splitting slices into lists by color, sorting a list, scrambling a list, and recombining separate lists to make a new slices list.
Code implemented in Java Note: Comments are written for code explanation Filename: Main.java public class Main { public static void main(String[] args) { GameWheel wheel = new GameWheel(); int totalPrizeMoney = 0; // flag variable keeps track of whet …
Not the question you’re looking for?
Post any question and get expert help quickly.
IMAGES