wood burning stoves 2.0*
The moose likes Game Development and the fly likes Yahtzee Class Diagram Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "Yahtzee Class Diagram" Watch "Yahtzee Class Diagram" New topic
Author

Yahtzee Class Diagram

William Koch
Ranch Hand

Joined: Sep 26, 2012
Posts: 76
I have no idea where to start when creating a class diagram. I am just drawing it out on a piece if paper so I do not need any special software at the moment. How do you know what all your classes need to be and how do you know what methods and fields/attributes that they are going to have? One thing to keep in mind (I do not know if this will affect any answers). This game I am creating needs to implement the strategy pattern, and it also needs to use the model view controller. Thanks a bunch.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3649
    
  17

William Koch wrote:This game I am creating needs to implement the strategy pattern, and it also needs to use the model view controller.


Why? "I need to hang this painting. I need to use glue". Even if glue will work, it seems ridiculous to limit yourself to a solution before you've even started exploring alternatives.

You can not know ahead of time everything that your program needs. Something always pops up during the design process. This is fine, it's how software is developed. Start with what (you think) you know for sure you'll need.

First of all, to me it seems pretty essential to keep track of each player's rolls. How about a ScoreCard class? A Yahtzee class can then keep track of ScoreCards and player turns. You also need a way to classify combinations: A Combination enum, that can calculate the score for a roll. Players also need to be able to choose how to reroll the dice, and select a category to put the points in. If you must, this is an opportunity to fit it the Strategy pattern.
William Koch
Ranch Hand

Joined: Sep 26, 2012
Posts: 76
The assignment requires that we build a game that has four players that play on their own (very basic AI) where each one has their own strategy (strategy pattern) and uses the model view controller the game needs to have a basic GUI.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11480
    
  16

The fact that each player has their own strategy does not require you to use a strategy pattern. I believe you would generally use the strategy pattern when the specific algorithm needs to be selected (or even changed) at run-time. If your specs lay out that player 'a' is going to use strategy 'a', then you are not choosing at run time.

I am not saying you SHOULDN'T use it...I'm just saying that it seems to me that you are deciding to use a hammer before you know if you need to tighten a screw, drill a hole, or pound in a nail.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5018
    
    8

William Koch wrote:This game I am creating needs to implement the strategy pattern, and it also needs to use the model view controller.

Words and semantics are very important when it comes to programming and I'm afraid that if you start out with this thought in mind, you'll definitely be at a loss as to where to start.

Rather than saying "The game needs to implement the strategy pattern and the MVC pattern," you should ask yourself "What design problem can be solved by implementing the strategy pattern?" which would lead you understanding exactly what the strategy pattern is and what kind of problems it is applicable to. You would ask the same kind of question about the MVC pattern. All this kind of thinking should lead you to the activity of breaking down your problem into smaller pieces or "concerns" which will make it easier for you to see which concerns can be addressed by an appropriate pattern.

I know this is all vague and general in nature but we like to help people think through their problems and come up with solutions on their own. Hopefully, this gives you some ideas about where you need to start in thinking your way to a solution. Good luck.


Junilu - [How to Ask Questions] [How to Answer Questions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Yahtzee Class Diagram