EECS2030 Lab 5

Tue Nov 1, Thu Nov 3, Mon Nov 7

Due date:
ALL SECTIONS: Thu Nov 10 before 23:59

Introduction

The purpose of this lab is to create a graphical user interface application to play the game rock, paper, scissors against the computer. In this lab you will:

Question: Rock, paper, scissors

The game rock, paper, scissors is usually played between two players. To play a round of rock, paper, scissors, the players count aloud to three, each time raising one hand in a fist and bringing it down on the count, and on the count of three each player simultaneously forms one of three shapes with their outstretched hand. The shapes are rock (a fist), paper (a flat hand), or scissors (a V formed by the index and middle finger). The winner of the round is determined by the following rules:

For this lab you will implement a graphical user interface application using the model-view-controller design pattern to play rock, paper, scissors against the computer. The application looks like the following immediately after you run it:


The three buttons labelled ROCK, PAPER, and SCISSORS allow the player to play a hand. Pressing a button causes the model to generate a random hand for the computer which is compared against the hand played by the player. The results are shown using the four labels. The top-most label shows the hand played by the player. The second label shows the hand played by the computer. The third label shows who won the round. The fourth label shows the cumulative results of all of the rounds played so far. After playing many rounds against the computer the application looks like the following:


The APIs for all of the classes and interfaces associated with this lab can be found here:

Pay attention to the package names! All of your classes must be in the package eecs2030.lab5

You are provided with partial or complete implementations of the following classes:

The class RPSUtils contains definitions of string constants that are used by the model, view, and controller. The remaining classes are heavily documented with instructions for completing them. I recommend completing them in the order view, model, controller, game. RPSView has a main method that you can run at any time to see your view (pressing the buttons won't do anything; you need to complete all of the classes to produce a runnable game). To run the finished program you should run the class RPSGame.

The view requires that you make labels having a nice border. To do so, you should use the javax.swing.BorderFactory class to create a border that can be added to a label. For example, to add a border to the view label that describes the hand played by the player you would write:

this.player.setBorder(BorderFactory
                .createEtchedBorder(EtchedBorder.LOWERED));

You can play the completed game by running the following program in the EECS Prism lab:

java -jar /cse/dept/www/course/2030/labs/lab5/RPS.jar

Submitting

Testers will be provided shortly; wait for the Moodle announcement before submitting your work.

Submit your program when you are finished:

submit 2030 lab5 RPSModel.java RPSView.java RPSController.java RPSGame.java

or if you are working in a group:

submit 2030 lab5 RPSModel.java RPSView.java RPSController.java RPSGame.java group.txt

Instructions for submitting from outside the lab can be found here.