• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Yahtzee Class Diagram

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Saloon Keeper
Posts: 15525
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic