1. Homepage
  2. Programming
  3. COMP2396 Object-oriented Programming and Java Assignment 4: GUI for Big Two card game

COMP2396 Object-oriented Programming and Java Assignment 4: GUI for Big Two card game

Engage in a Conversation
HKUCOMP2396Object-oriented Programming and JavaBig Two card gameJava

COMP2396 Object-oriented Programming and Java
CourseNana.COM

Assignment 4 CourseNana.COM

This assignment tests your understanding of GUI and event-handling, and their implementations in Java. You are going to design and implement a GUI for the Big Two card game you developed in assignment 3. In addition to the classes and interface provided in assignment 3, a CardGameUI interface is provided to model a user interface for a general card game. You may refer to their Javadoc for details of these classes and interfaces. You should NOT modify any of these provided classes and interfaces in completing your assignment. CourseNana.COM

You will be reusing all the classes implemented in assignment 3. You are required to implement a BigTwoGUI class which builds a GUI for the game and handles all user actions. This class implements the CardGameUI interface and has several inner classes responsible for rendering the user interface and handling user actions. To make use of the BigTwoGUI class, you will need to modify your BigTwo class accordingly. You will need to replace the BigTwoUI object with a BigTwoGUI object. You are free to introduce new instance variables and methods to these classes. Besides, you are also free to design and introduce new classes in the inheritance trees as appropriate. With a proper OO design, you do not need to touch the rest of the classes in assignment 3. You are required to write Javadoc for all public classes and their public class members. CourseNana.COM

Specifications CourseNana.COM

Graphical user interface CourseNana.COM

You are free to design a GUI for your Big Two card game. As a minimum requirement, your GUI should CourseNana.COM

  • Have a panel showing the cards of each player as well as the cards played on the table. The cards should be shown in a partially overlapped manner (see Figure 1). CourseNana.COM

  • For each player, the panel should show his/her name and an avatar for him/her. CourseNana.COM

  • For the active player, the panel should show the faces of his/her cards. CourseNana.COM

  • For other players, the panel should show only the backs of their cards. CourseNana.COM

  • For cards played on the table, the panel should show at least (the faces of) the last CourseNana.COM

    hand of cards played on the table and the name of the player for this hand. CourseNana.COM

  • Allow the active player to select and deselect his/her cards by mouse clicks on the cards. The selected cards should be drawn in a “raised” position with respect to the CourseNana.COM

    rest of the cards (see Figure 1). CourseNana.COM

  • Have a “Play” button for the active player to play the selected cards. Nothing should CourseNana.COM

    happen if the Playbutton is clicked with no card selected. CourseNana.COM

  • Have a “Pass” button for the active player to pass his/her turn to the next player. CourseNana.COM

  • Have a text area to show the current game status as well as end of game messages. CourseNana.COM

  • Have a text area showing the chat messages sent by the players. CourseNana.COM

  • Have a text input field for the active player to send out chat messages. CourseNana.COM

Deadline: 11:55pm, 22nd Nov, 2023. CourseNana.COM

Overview CourseNana.COM

  • Have a “Restart” menu item under a “Game” menu for restarting the game. CourseNana.COM

  • Have a “Quit” menu item under a “Game” menu for quitting the game. CourseNana.COM

  • Your application window should support maximizing, minimizing, and resizing. CourseNana.COM

    The BigTwoGUI class CourseNana.COM

    The BigTwoGUI class implements the CardGameUI interface. It is used to build a GUI for the Big Two card game and handle all user actions. Below is a detailed description for the BigTwoGUI class. CourseNana.COM

    Specification of the BigTwoGUI class: CourseNana.COM

    public constructor: CourseNana.COM

    BigTwoGUI(BigTwo game) a constructor for creating a BigTwoGUI. The parameter game is a reference to a Big Two card game associated with this GUI. CourseNana.COM

    private instance variables: * CourseNana.COM

    BigTwo game a Big Two card game associated with this GUI. CourseNana.COM

    boolean[] selected a boolean array indicating which cards are being selected. CourseNana.COM

    int activePlayer an integer specifying the index of the active player. CourseNana.COM

    JFrame frame the main window of the application. CourseNana.COM

    JPanel bigTwoPanel a panel for showing the cards of each player and the cards played on the table. CourseNana.COM

    JButton playButton – a “Play” button for the active player to play the selected cards. JButton passButton – a “Pass” button for the active player to pass his/her turn to the CourseNana.COM

    next player. CourseNana.COM

    JTextArea msgArea a text area for showing the current game status as well as end of game messages. CourseNana.COM

    JTextArea chatArea a text area for showing chat messages sent by the players. CourseNana.COM

    JTextField chatInput a text field for players to input chat messages.
    *
    These are just suggestions to aid your design. It is perfectly fine if your actual CourseNana.COM

    implementation deviates from these suggestions. CardGameUI interface methods: CourseNana.COM

    void setActivePlayer(int activePlayer) a method for setting the index of the active player (i.e., the player having control of the GUI). CourseNana.COM

    void repaint() a method for repainting the GUI.
    void printMsg(String msg) a method for printing the specified string to the message CourseNana.COM

    area of the GUI.
    void clearMsgArea() a method for clearing the message area of the GUI. CourseNana.COM

    void reset() a method for resetting the GUI. You should (i) reset the list of selected cards; (ii) clear the message area; and (iii) enable user interactions. CourseNana.COM

    void enable() a method for enabling user interactions with the GUI. You should (i) enable the “Play” button and “Pass” button (i.e., making them clickable); and (ii) enable the BigTwoPanel for selection of cards through mouse clicks. CourseNana.COM

void disable() a method for disabling user interactions with the GUI. You should (i) disable the “Play” button and “Pass” button (i.e., making them not clickable); and (ii) disable the BigTwoPanel for selection of cards through mouse clicks. CourseNana.COM

void promptActivePlayer() a method for prompting the active player to select cards and make his/her move. A message should be displayed in the message area showing it is the active player’s turn. CourseNana.COM

inner classes: * CourseNana.COM

class BigTwoPanel an inner class that extends the JPanel class and implements the MouseListener interface. Overrides the paintComponent() method inherited from the JPanel class to draw the card game table. Implements the mouseReleased() method from the MouseListener interface to handle mouse click events. CourseNana.COM

class PlayButtonListener an inner class that implements the ActionListener interface. Implements the actionPerformed() method from the ActionListener interface to handle button-click events for the “Play” button. When the “Play” button is clicked, you should call the makeMove() method of your BigTwo object to make a move. CourseNana.COM

class PassButtonListener an inner class that implements the ActionListener interface. Implements the actionPerformed() method from the ActionListener interface to handle button-click events for the “Pass” button. When the “Pass” button is clicked, you should call the makeMove() method of your BigTwo object to make a move. CourseNana.COM

class RestartMenuItemListener an inner class that implements the ActionListener interface. Implements the actionPerformed() method from the ActionListener interface to handle menu-item-click events for the “Restart” menu item. When the “Restart” menu item is selected, you should (i) create a new BigTwoDeck object and call its shuffle() method; and (ii) call the start() method of your BigTwo object with the BigTwoDeck object as an argument. CourseNana.COM

class QuitMenuItemListener an inner class that implements the ActionListener interface. Implements the actionPerformed() method from the ActionListener interface to handle menu-item-click events for the “Quit” menu item. When the “Quit” menu item is selected, you should terminate your application. (You may use System.exit() to terminate your application.) CourseNana.COM

* These are just suggestions to aid your design. It is perfectly fine if your actual implementation deviates from these suggestions. CourseNana.COM

Sample output CourseNana.COM

Figure 1 shows an example of GUI for the Big Two card game that satisfies the minimum requirement1. You are not required to reproduce the same GUI exactly. CourseNana.COM

Figure 1. An example of GUI for the Big Two card game. CourseNana.COM

Marking Scheme CourseNana.COM

Marks are distributed as follows: CourseNana.COM

  • -  Implementation of the BigTwoGUI class
    o Rendering of players’ cards and cards on the table (20%)
    o Implementation of card selection using mouse clicks (20%) o Implementation of the game message area (5%)
    o Implementation of the chat message area (5%)
    o Implementation of the chat input field (5%)
    o Implementation of the “Play” button (5%)
    o Implementation of the “Pass” button (5%)
    o Implementation of the “Restart” menu item (5%)
    o Implementation of the “Quit” menu item (5%)
    o Overall design of the GUI (10%) CourseNana.COM

  • -  Integration with the BigTwo class (5%) CourseNana.COM

  • -  Javadoc and comments (10%) CourseNana.COM

You may download the card images used in this https://www.waste.org/~oxymoron/cards/. You are free to use any other card images. CourseNana.COM

CourseNana.COM

Submission CourseNana.COM

Please pack the source code (*.java) and images of your application into a single zip file, and submit it to the course Moodle page. CourseNana.COM

A few points to note: CourseNana.COM

  • -  Always remember to write Javadoc for all public classes and their public class members. CourseNana.COM

  • -  Always remember to submit the source code files (*.java) but NOT the bytecode files (*.class). CourseNana.COM

  • -  Always double check after your submission to ensure that you have submitted the most up-to-date source code files. CourseNana.COM

  • -  Your assignment will not be marked if you have only submitted the bytecode files (*.class). You will get zero mark for the assignment. CourseNana.COM

  • -  Please submit your assignment on time. Late submission will not be accepted. ~ End ~  CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
HKU代写,COMP2396代写,Object-oriented Programming and Java代写,Big Two card game代写,Java代写,HKU代编,COMP2396代编,Object-oriented Programming and Java代编,Big Two card game代编,Java代编,HKU代考,COMP2396代考,Object-oriented Programming and Java代考,Big Two card game代考,Java代考,HKUhelp,COMP2396help,Object-oriented Programming and Javahelp,Big Two card gamehelp,Javahelp,HKU作业代写,COMP2396作业代写,Object-oriented Programming and Java作业代写,Big Two card game作业代写,Java作业代写,HKU编程代写,COMP2396编程代写,Object-oriented Programming and Java编程代写,Big Two card game编程代写,Java编程代写,HKUprogramming help,COMP2396programming help,Object-oriented Programming and Javaprogramming help,Big Two card gameprogramming help,Javaprogramming help,HKUassignment help,COMP2396assignment help,Object-oriented Programming and Javaassignment help,Big Two card gameassignment help,Javaassignment help,HKUsolution,COMP2396solution,Object-oriented Programming and Javasolution,Big Two card gamesolution,Javasolution,