For this year's final project, you are to design a version of the game Yahtzee. You will be working with random numbers and arrays in your program to write your game. Attached below is a word document with the rules for how my game is played and the scoring rules for the game. My version is different from the standard game, which means the coding will be different from the many versions that are already out on the web. This will be a challenging program, so you will be given four weeks in which to complete it. The due date is 6/23/20. As far as pacing your project, my recommendation would be that you have the dice array working by early next week. Have the scoring array working by June 10th. Have the scoring for a single game working by June 17th, and finish putting all the pieces together by June 23. As always, I am available for questions. I want you to think of this last project as a challenge to show what you are able to accomplish on your own and have some fun trying to figure it out like you would a puzzle. You may work with other people on this project. As long as I get individual emails from each person in a group to tell me they are part of the stated group, all will get credit. I will ask each person in a group to specify what part of the project is their responsibility. And finally, I am well aware that there are a number of different code versions of the game out there on the web. If you want to cut and paste somebody else's code, and submit it as your own, you will receive 0 credit for the assignment. Most such cases will be immediately evident to me by A) The program not playing the game the way I asked you to write the code B) The usage of various programming techniques that are not discussed until a student is in my AP programming class. Should there be any doubt, you will be asked to explain, in detail, what various sections of your code is doing in your program.
Attached are the answers and code for the assignment that was due on 4/27. See the attached files for working source code. (I have also included again a copy of the assignment from 4/27 so you don't have to go back to find it in a prior post.) Most people had the right answers. The most common common mistakes were when people mixed up the value of the index itself of the array with the value at the POSITION of the index. So if the index is 3, arrayName[3] will equal whatever VALUE is stored at INDEX position 3 which is the FOURTH element in the array since the index starts at position 0. In the answer keys attached below, included is the code solution for each problem as well as the answer you should have gotten. I have broken down the code for the individual questions with detailed comments explaining why the lines of code are there. The notes are fairly detailed and I think it should enable you to fix the errors in your program. If you still can not fix your program, email me again with the part on which you are having difficulty. Answers for questions 1 - 5 Question 1. 20 Question 2. 20 Question 3. 22 Question 4. x= 23, y=25 Question 5. x= 21, y=11 Next assignment - Due Friday 5/22/20. 3 parts. 1) If your have not already done so, use the comments and notes in the source code in the attached files below to get your program to work correctly. 2) For problems 6 - 10, change the integer array a from int[a] = new int[10]; to int[a] = {-3,6,9,10,17,19,20,28, 34, 45, 50}; Note this new array a has 11 elements, so if you hard coded your program to loop from index position 0 to 9 (10) elements or in some way wrote your code to assume the array had exactly 10 elements, your code will not work correctly. Review my example to see how and why it will work no matter what the size of array a is. Hint a.length Get the program to work correctly for the new size. 3). Use a random number generator to: a) Create an array a of a random size between 25 and 50 elements (inclusive). b) Use the random number generator to now fill in the array with random integers in the range from -100 to 100 (inclusive). (So if in step 1 you created an array a that has a size of 36, now generate 36 random numbers in the range from -100 to +100, one at a time, (use a loop) and add them into the array a you created in step a). c) Run steps 6 through 10 from the previous assignment on the new array you created. (Add 1 to each element in the array, count the number of negative elements, print the elements in reverse, etc.) d) Use a println statement to make sure your program runs correctly.
Attached below is an assignment on arrays with 8 questions. Please submit your answers by Friday - 5/8/20. You need only copy and paste your answers in an email to me. Reminder - when you declare an array of some object type, it does not have to be only a primitive data type like int or double. Example: I have an array of object types called whozeewhatsits. I have no idea what they are or what they do but I can still create an array of them. So if I want a 100 element array of whozeewhatsits named as myArray, the code would be whozeewhatsits[ ] myArray = new whozeewhatsits[100]; Good luck and stay healthy!
|
Archives
May 2020
Categories |