• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Dice Game model

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

For a design pattern class I have a little application to make using design patterns.

I have developped the model of this application, but honestly I don't know if it's correct. Can anyone give me some insight on it.

The question is:


* A Dice Game
* A Player rolls 10x 2 dices
* If result = 7, score=score + 10 points
* At the end, score of the player is registred in a database

I have come up with the following class diagram:



Basically the game starts, the game object uses 2 dices and a player object. each time the rollDices() method is called, the two dices are rolled and the score is incremented if necessary. At the end of the game the score and the player name are persisted in tthe database.
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which design pattern are you trying to use in your design?
 
Tadili Saad
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I will use the abstract factory (or factory method) for the dao.
Probably the observer for the view-model.
Singleton in dao, controller...

And MVC pattern for the whole application.

But before starting I wanted to make sure that my model was correct and I didn't miss anything.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There shouldn't be two relationship symbols connecting the Dice class and the Game class. There should only be one. When you want to "optionally" include multiplicity in the relationship between two classes, you add the number near the class that it applies two. In this case, it would be a small two.

Keep in mind that a Class diagram is typically for describing classes, not run-time objects. It is usually best not to include run-time information in Class diagrams. Any important information can be included as a Note, which is a very helpful UML tool.
 
Tadili Saad
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Frank Bennett wrote:There shouldn't be two relationship symbols connecting the Dice class and the Game class. There should only be one. When you want to "optionally" include multiplicity in the relationship between two classes, you add the number near the class that it applies two. In this case, it would be a small two.

Keep in mind that a Class diagram is typically for describing classes, not run-time objects. It is usually best not to include run-time information in Class diagrams. Any important information can be included as a Note, which is a very helpful UML tool.



Thank you, I will change the multiplicity.

But actually by a correct model I was meaning did I forgot to add some class in the model, is the modelisation not correct semantically ?
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a "design" there is rarely a "correct" and an "incorrect." There are shades of good and shades of bad and a bunch of cloudy possibilities in the middle.
What you currently have is a single design. Someone else could create a totally different design. Neither one would be classified as "correct."
 
Tadili Saad
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess I'll just continue on the modeling and programming and see if I made the correct choices.

thank you.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That sounds like a correct decision Good luck with your assignment!
 
And then the entire population worshiped me like unto a god. Well, me and this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic