# Design patterns how?

Page 1 of 1

## 2 Replies - 1310 Views - Last Post: 23 November 2006 - 11:37 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=21174&amp;s=ac5549eb36eea108e507e19a275ba752&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 steve22

Reputation: 0
• Posts: 9
• Joined: 23-October 06

# Design patterns how?

Posted 21 November 2006 - 04:13 PM

Hi guys....

I wanna make this below coding into design patterns. but im not sure how its dun...Can sumone give me an example of how its dun with my coding plz.

Thanks
for (enter = human; enter < numberofplayers;
enter++) {
switch (aileveltype[k++]) {
case 1:
chc = (int) (Math.random() * 5);
stk = 1 + (int) (Math.random() * cash[enter]);
System.out.println(player[enter] + " selected " + chc
+ " with stakes " + stk);
break;
case 2:
chc = (int) (Math.random() * 5);
stk = 1 + (int) (cash[enter] / 2);
System.out.println(player[enter] + " selected " + chc
+ " with stakes " + stk);
break;

case 3:
chc = (int) (Math.random() * 5);
stk = 1 + (int) (cash[enter] / 4);
System.out.println(player[enter] + " selected " + chc
+ " with stakes " + stk);
break;
}
choices[enteramount] = chc;
stakes[enteramount] = stk;
cash[enteramount]-=stakes[enter];
}

}

Is This A Good Question/Topic? 0

## Replies To: Design patterns how?

### #2 salindor

• D.I.C Regular

Reputation: 46
• Posts: 301
• Joined: 10-November 06

## Re: Design patterns how?

Posted 21 November 2006 - 05:03 PM

What kind of design pattern are you trying to get? There are several

This post has been edited by salindor: 21 November 2006 - 05:06 PM

### #3 steve22

Reputation: 0
• Posts: 9
• Joined: 23-October 06

## Re: Design patterns how?

Posted 23 November 2006 - 11:37 AM

Hi

salindor
i need to apply the
Strategy" pattern

but im not sure how to apply it. to my coding