Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Ninth Java Assignment: GUI for Card Game Ninth Java Assignment: Card Game, Revisited David Matuszek Your third assignment was to write a simulation of a simplified card game, "21." There was a Dealer (who did not play) and three computer Players. This is the same assignment again, with a few differences. Players There are still three players, but this time one of them is human. Players 1 and 2 are computer players, you are the third player. You still need a class Player, but this time it should have two subclasses, ComputerPlayer and HumanPlayer. Player should be an abstract class: it should declare, but not define, the method play(). Player had an instance method play() which decided whether or not to ask for another card. You can use this old method for the computer player, but you need to write a new play() method for the human player. The difference is that the play() method in HumanPlayer will let you decide whether to take another card. The GUI The game you wrote before is basically the model; it does the actual work of the game. It was actually a little more, because the various System.out.println statements that you put in it formed a view. These print statements can now be eliminated, or (better) commented out. (If you haven't ever used BlueJ's Comment menu item, you should learn how to use it.) For this assignment, you need to construct a GUI. As with most small programs, it's probably better to combine the controller and the view in the GUI class. However, keep GUI information out of the model; the model should be independent of the GUI. If the GUI needs information from the model that is not easily available, you should add methods to the model that the GUI can use to get the information it needs. (Hint: if BlueJ shows a dotted arrow from a model class to a GUI class, that means the model is using something in the GUI, and is therefore not independent of the GUI.) Your program should display the same information as a human would see when playing the game: your own hand, the visible card of each player, and whether each player takes another card, or passes. When the game ends, the program should tell each player's total hand, and who won. The design of the GUI is up to you. You design it, you implement it. I would recommend starting with the simplest GUI you can think of; then, when you have the program working, improve the GUI. You can write the program as an application or as an applet. Your choice. Good comments are expected and required. So is good style. Code reuse By all means, use as much of your earlier program as you can. If you need to modify your old program or rewrite it, do so. I intend to post my version on the web, and you can use that if you like. Extra credit You will get extra credit points for having an exceptionally nice GUI. In a non-computer version of this game, players would show their complete hand at the end. We didn't do this before because we didn't yet have arrays, so we only kept a total card count. Now, if you like, you could keep the cards in an array, and show them at the end. (You can assume no player takes more than 21 cards.) You may get extra credit for other features, such as being able to play multiple games. Be sure that these extra features are obvious from looking at the GUI, though; if we don't notice it, you don't get points for it. Due date This program is due by midnight Wednesday, November 28. Please turn in a complete BlueJ package via Blackboard. Late penalty will be 5 points per day, and programs will not be accepted after Monday, December 3.