唉。。。大牌很纠结啊!

SHAOYIOU 2009-10-30 05:20:24

A Hand of Bridge

1 Purposes
1)To give you practice in designing and using classes and objects
2)To give you practice using arrays
2 General idea of the assignment
2.1
General idea Play a hand of bridge.
Don’t worry-- you don't actually have to know bridge in order to do this assignment. In fact, thisassignment is "inspired by" bridge in the same way that a movie is "inspired by" a true story. I'm providing some very simplified rules. If you do know how to play bridge, please accept my apologies--but the assignment is still to write a program to play this version, not the real game.
2.2
The rules
A deck of cards consists of 52 cards--13 each in four different suits. The four suits are called Spades, Hearts, Diamonds, and Clubs. Each card in a suit has a number from 1 to 13. Hence we have cards such as "the 4 of Spades" or "the 13 of Diamonds." (We do not have Ace, Jack, Queen, King cards, just numbered cards.)
There are four players, whom we will call North, East, South and West. Any player can act as the "dealer."
Here's how it goes:
1.The dealer "shuffles" the deck. This randomizes the order of the cards, but there are still 52 different cards--no card ever occurs twice.
2.The dealer "deals" the cards; that is, she gives 13 cards to each player, including herself. The 13 cards held by a player are that player's "hand."
3.One of the players is chosen (I don't care how) to "lead," that is, to play the very first card.
Next, thirteen "tricks" are played. Each trick proceeds as follows:
1.The chosen player plays the first card. "Playing a card" means removing it from her hand and letting the other players know which card it is. (In the real game, the card is placed face up on the table.) It is important to notice what the suit of this card is. In this simplified game, any card may be played as the first card of a trick (the players have no strategy or any idea of a "good" card to play).
2.Each of the remaining players then plays a card. If a player has any cards of the same suit as the first card played, then she must "follow suit" (play a card of the same suit). If she has no cards of the same suit, she may play any card.
3.When all four players have played a card, the player who played the highest-numbered card of the first suit played "takes the trick"--she collects and puts aside all four cards (we can ignore this bit--you don't need to keep track of the cards after the trick has been played). This player is then chosen to lead (play the first card of) the next trick. 1
After doing the above 13 times, all cards have been played and the hand ends. The program ends, too.
There is no strategy to this game, it isn't scored, nobody wins or loses. It's a stupid game, OK?
2.3
Partial Example (one trick)
After the cards are shuffled and dealt:
1.North plays the 5 of Hearts
2.East plays the 8 of Hearts
3.South (who has no Hearts) plays the 12 of Diamonds
4.West plays the 1 of Hearts
Since the first card played was a Heart, the player who played the largest Heart (East, with the 8 of Hearts) collects the four cards, and "leads"--chooses any card from her hand (of any suit) to start the next trick. Whatever card East chooses, the other three players must play cards of the same suit, if possible.
3 Y
our assignment
I will suggest what classes you need (and you may have more, if you like), but it's up to you to decide what their instance variables and their methods should be.
Use the objects you define to play a hand of "bridge."
Print out at least:
Who gets dealt which cards
For each trick:
who leads,
who plays which cards, and

who takes the trick.
4 Structure of this assignment
Project name: Bridge
Package name: bridge
Suggested classes:
class Bridge -- contains the main method. Controls the game.
class Card -- represents one card. Has a suit and a value. You can find out what the suit and value are, but you can't change them.
class Player -- represents a player. Every player knows how to shuffle, how to deal, and how to play cards.
Provide UML class Diagrams
The above are requirements. You may have additional classes and methods as needed, and they should be documented and unit tested as appropriate.

5 Due date
Wednesday, November 04, before midnight. Hand in one project with both your names on it; zip up the entire project directory and hand it in via Course Management System.
...全文
118 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Agile牧 2009-11-01
  • 打赏
  • 举报
回复
这是。。。。。
jackalanfang 2009-10-31
  • 打赏
  • 举报
回复
....
lotusandjava 2009-10-31
  • 打赏
  • 举报
回复
............

23,404

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧