This site requires JavaScript, please enable it in your browser!
Greenfoot back

Discussions

You need to login to take part
Rss

Current Discussions

Nameisjonny

Lost on how to do a lab. Can anyone help?

By Nameisjonny, with no replies.
Goal: This is comprehensive lab that will require you to apply all the skills learned on the course (i) problem solving, (ii) prototype design, (iii) implementation using Greenfoot and Java and (iv) testing it to make sure it works as expected. Objective: To meet the goal stated above you design your own Greenfoot scenario for a given problem. Also make use of (i) method definition and call (ii) repetition control structure in for loop and while loop and selection control structure in if..else, (iii) definition of a user-defined World, (iv) definition of user-defined Actors and “act” method (understand the act method), and (v) adding objects and strings to the scenarios. We will also learn modular development using methods. We will also learn to use the animations methods we studied. The problem: You are required to create a scenario that plays the game Craps. (Don’t worry we will explain what Craps is.) Craps algorithm: Craps is a game played with a pair of six-faced dice. While there are many variations of the game, we will use a simplified version as explained below: 1. Initial round: a. A played rolls a pair of dice. b. Let the sum of the die1 value and die 2 value be called points. c. If the points is 7 or 11, the player wins and the game ends. d. If the points is 2,3 or 12, the player loses and the game ends. e. If the points is anything other than above go to step 2 for continuing to play, 2. Subsequent rounds: a. The player rolls the pair of dice again. b. Let the sum of the dice be called nextPoints. c. If the nextPoints is same as points scored in the initial round, then the player wins and the game ends. d. If the nextPoints is 7, the player loses and the game ends. e. If the nextPoints is anything other than the above two (c., d.) then the player continues to roll and rules of the subsequent rounds apply. What to do and How to do it? We will develop the solution for the problem in incremental steps. 1. Get a pair of dice and play the game as specified above. It helps to have a friend around so that you can discuss the game with him/her. Understand the various outcomes of dice rolls and the rules for each of these, Specifically make sure you understand what are conditions for terminating the game and the conditions for continuing the game, and also the conditions for a win or a loss. 2. In order to understand programming requirements, we will first develop a prototype to implement the algorithm given above. a. Define a CrapsWorld class as a subclass of World b. Define a Craps class as a subclass of Actor. c. Connect the two by instantiating Craps object inside the CrapsWorld. d. Inside Craps class develop the program for the algorithm given above in steps: code only the “Initial round” and test it. Then develop the code for “subsequent round”. Implement the code using meaningful methods. e. Test the complete program and make sure it works for all cases. 3. After you have completely tested the correctness of the logic, then take the components of the scenario and add animations. For example, the die can be animated. The roll can be animated. You can add other actors like people, trees and barrels (!) to the scenario and make them move around etc. The sky is the limit. Show your originality and creativity.