
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Purpose: The purpose of this programming assignment is to give you more practice in problem solving, class design, methods, and event-driven applications, in addition to practice with the new topics of exception handling and file processing. Exception handling gives us the power to create more robust programs. Files give us persistent data so that we can save the results of our processing for later access. Both of these new concepts are essential for real world applications. Preparation: In your textbook, you should read sections: 15.1 – 15.6 and 17.1 – 17.6. In class we have been and will continue to cover several concepts which will help you to write this application. Problem: You are to write an application that plays the game of Jan-ken-pon (see rules below). Jan-ken-pon game rules: Jan-ken-pon is a simple game where each player uses a hand to form one of three choices: a rock, a pair of scissors, or a sheet of paper. Players each swing their fists while shouting "jan, ken, pon! " On “pon” both players show his/her choice of rock, paper, or scissors at the same time. A clenched fist represents a rock and is called "gu", all fingers spread out is paper called "pa", and extended index and middle fingers are scissors called "choki". The game is decided by the following rules: rocks break scissors, scissors cut paper, paper covers rock. http://www.tadaima.com/misa/jan- ken-pon.htm Requirements : You will design an abstract class called Strategy that will have a String name and an abstract method called choice. The String name will identify the particular Strategy , while the choice method will somehow select rock, paper, or scissors. You will need at least two subclasses to more specifically define Strategy ’s. For example, you could have a RandomStrategy that selects the next choice based on Math’s random number generator method. You could also have a strategy that allows user input so that a human could play. This could be the HumanStrategy. You will also need a Game class that will be composed of two Strategy ’s. So, when your program makes a call to a Game constructor, you will need to provide two Strategy ’s to play each other. Game objects will play, so there will be an instance method of the Game class called play. Your driver class will create Game objects and will write the results of each game to a file. After, say, one hundred games are played, your program will read the file and will display a nice report which shows the number of times each Strategy won the game. You should test-first and incrementally build your program. Use methods with parameters where appropriate. Use exception handling where appropriate. Create a nice, standard, intuitive GUI which uses JFileChooser. Get one small thing tested, coded, and working, and then add something else. This way you should always have working code. Be sure to turn in a class diagram to show the relationships between your classes. You should have at least five classes, one which is the driver.