Java代写 | Assignment 4: Modular Coding Style With MVC

本次Java代写是使用gui实现一个blackjack的游戏

Assignment 4: Modular Coding Style With MVC
In the last assignment we made some basic GUI elements to help display a game of blackjack. We had a couple of minimal
model elements, view elements, and control elements, but no clean separation between them.
In this assignment, we will implement a model-view-controller design pattern. The model has been written for you. It is a
class called BlackJackModel. It provides all the methods and game state needed to play BlackJack. It handles data and
application logic. Your job is to finish making two classes; BlackJackView and BlackJackApplication, which will act as the
controller, and link all three classes in a proper MVC format, at which point the game should be playable.
At this point we will add some Alerts and Dialogs to the game to complete the experience.
When you submit, all source code files must be in a package named assign4, and submitted in a zip file assign4.zip. That is,
zip up the package containing your source code and your README.txt (described below) and submit that. Failure to submit
in the code in the proper package, or using some other file structure is -5 marks.
In this assignment there will be 5 style marks as well. So well documented, easy to read code. Each question is worth 5
marks, including the bonus question. The total is out of 45 (with up to 10 bonus marks).
You can modify GUI elements, layout elements (except where forbidden), Unicode elements, etc, to make a better looking
GUI, as long as the functionality remains the same. Up to 5 bonus marks will be awarded for creativity and design
1) In BlackJackView.java, there are some components instantiated, but not displayed. Place all of these components as
follows using a GridPane or BorderPane. You may use an additional pane for the bottom row of buttons and labels if you
wish.
The different components are labeled below.
DealerPane: PlayerPane:
The buttons and label (which currently says “Bet placed!”):
2) In BlackJackView.java, write getters for the control elements (they are also listed in the code comments). Write getters
for ‘newDeal’, ‘hitMe’, and ‘stay’ button. Also write a getter for the “placeBet” button, which you will have to get from the
PlayerPane. Write a getBet() method that returns the result of calling ‘getBet()’ on the PlayerPane object. We will use the
value returned from getBet() to update the model in the next step.
3) Fill in the “update()” method by taking information from the model and putting it in the appropriate view element. You
must update the Player’s hand, the Dealer’s hand, the bet, the cash, and the message. The model has public methods you can
call for each of these things.
4) In BlackJackApplication.java, instantiate the model and the view.
5) Implement event handlers for the four buttons contained in the view (placeBet, newDeal, hitMe and stay). You do not
have to figure out the implementation logic; that has been handled (though you might stumble on some bugs). In the event
handler you should call the appropriate method from the model, and then call update on the view. There are methods in the
model that correspond to the button names; these are the methods you should call. You may use helper functions if you
wish.
At this point things should work. Playtest your BlackJack application to make sure you have implemented things properly.
Part II: Alerts and Dialogs
In this part we will implement Alerts and Dialogs where appropriate. Do do this, we will also implement a little bit of
application logic.
6) Currently, when the player presses the “Stay” button, the game completes and a message is displayed on a Label. In this
part you will make an Alert that pops up and displays the message (there is a method in BlackJackModel called
getMessage() that returns a String). Hint: you should do this in the “stay” event handler (or helper function).
However, we only want this to display when appropriate. There is a method in BlackJackModel called “canStay()”. First we
check if “canStay()” returns true, and if it does, update the model and view as before. Then make and display an Alert that
displays the message from the model (use the getMessage() method from BlackJackModel).
7) In the event handler for the “hitMe” button, we want to display an Alert if the player busts. However we also want to
make sure the Alert does not display at inappropriate times. There is a method in BlackJackModel called “canHit()” that
returns a boolean. The first thing you should check is this method.
If the player “canHit()”, update the model and view as before. After you update the model and the view, there is another
method in the model called “playerBusted()” which returns a boolean. Check if the player has busted, and if they have,
display an Alert saying that the player has busted.
8) (Bonus) When the player presses the “placeBet” button, instead of moving the bet from one TextField to another, we
want a dialog pop up that asks for the player’s bet. We will then use the bet from that dialog to update the model and view.
However, we don’t want this to pop up in the middle of a game. So there is a method in BlackJackModel called “canBet()”
that returns a boolean. First check if “canBet()” returns true, and if it does, display the dialog and take the player’s bet, and
use this value to update the view and model. If it is false, you can simply return. You can disable or set the “next bet” Label
and TextField to invisible, delete them, or leave them where they are.
9) Document everything that does not work or you did not finish in a README.txt file.


程序代写代做C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: [email protected]  微信:dmxyzl003


如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。

发表评论