CS 314 Specification 4 - Designing and Implementing a Program With Multiple Classes - MasterMind
Programming Assignment 4: Pair Assignment. You may work with one other person on this assignment using the pair programming technique. Your partner can be in any CS314 section taught by Mike. Review this paper on pair programming. You are not required to work in a pair on the assignment. (You may complete it by yourself if you wish.) If you begin working with one partner and do not wish to finish the assignment with that partner you must complete the assignment individually. If you work with a partner, the intent is that you work together, at the same computer. One person "drives" (does the typing and explains what they are doing) and the other person "navigates" (watches and asks questions when something is unclear). You shall not partition the work, work on your own, and then put things together.
You and your partner may not acquire from any source (e.g. another student or an internet site) a partial or complete solution to a problem or project that has been assigned. You and your partner may not show other students your solution to an assignment. You may not have another person (current student other than your partner, former student, tutor, friend, anyone) “walk you through” how to solve an assignment. You may get help from the instructional staff. You may discuss general ideas and approaches with other students. Review the class policy on collaboration from the syllabus. If you took CS314 or CS307 in a prior semester and worked with a partner you must start from scratch on the assignment. If you took CS314 or CS307 in a prior semester and did this assignment on your own and want to work with a partner this term you must start from scratch.
The purpose of this assignment is to design and implement a program with multiple classes
|Sample output||SampleOutput.txt. A text file that shows what the output of the game could be. You do not have to follow this format exactly, but yours should be similar.||Provided by me.|
|Implementation||MastermindDriver.java||Provided by me. DO NOT ALTER. This is how we will run your game.|
|Implementation||Game.java||Provided by you and me. (Mostly you)|
|Implementation||Other classes you create for the game of Mastermind.||Provided by you.|
|Testing||MasterMindTest.java. Create a testing class for your program.||Provided by you|
|Submission||A4.jar. JAR of the program, including the source code for all classes you created plus Game.java, MasterMindTest.java and MastermindDriver.java.||Provided by you.|
Submission Requirement: Because you are designing the classes for this program, we don't know what the class names will be. Therefore your submission will be a jar file. jar is a program included in the standard edition of Java loaded on the computers in the Microlab and that you have on your computer if you downloaded Java. Some IDEs provide the ability to create jar files.
Here is a link
to how to create
jar files in Eclipse.
If you are not using Eclipse
you can use jar from the command line.
The archive tool we use in the class is called jar. (Java ARchive) I strongly recommend learning to use that tool well before the due date. In the past students have had trouble turning in the assignment on time because they did not allow enough time to learn to use jar. jar can be used to create executable Java programs and to archive multiple files into a single file. You will be using jar to create an archive, not to create an executable, so there is no need to include the .class files.
You can test your jar is correct by creating a new Java Project in Eclipse and adding your jar to it by selecting File -> Import -> General -> Archive file. Browse to the location of your jar and choose it. Look at the resulting project and see if the files you thought your jarred are actually added. Alternatively you could use a zip program to look at the contents of your archive file.
Do not include any directory structure in the jar. This means if you
have an Eclipse project and an src folder the directory structure is NOT
preserved. This is an option when creating the jar. (see the images on the
handout for creating jars)
IMPORTANT: You must include the .java files in the jar, not the .class files. If your jar does not contain your source code (your .java files) you and your partner will receive a 0 on the assignment. It is vital that you do not to wait until the last minute to learn how to create jar files and that you test your jar to ensure the .java source code files are in it.
If you need help creating jar see the instructor, a TA, or a proctor during lab hours.
Under the constraints of the General Assignment Requirements, design and implement a program to play a text based version of the board game Mastermind. You are free to use whatever classes and methods from the Java standard library you wish to use.
Read the Wikipedia article on the game of Mastermind. If you have never played Mastermind there are numerous online versions such as this one.
The version of the game you implement will have the following properties.
The output of the game should be a simple text based display. Look at this page for sample output. (User responses are in bold italics.) Your program does not have to match this output exactly but should be similar.
Part of the assignment grade will be determined by how easy it would be to alter your program to allow a different number of guesses before the user loses, a different number of pegs in the code, and how easily different colors could be added, assuming they start with a different letter than other existing colors. (Up to 26, one for each capital letter. Are there any colors that start with an X?) For example how easily would it be to change the code to have 5 pegs and allow pegs to be the color Maroon? A valid solution would be to ask the user for this information at the start, although this is not required.
Part of the assignment grade is based on breaking the problem up into a number of small, simple classes. One of the criteria of the assignment is to break the problem up into multiple classes even if you think the problem could be solved more easily with no discernible structure or one big class. For this assignment you should err on the side of having lots of simple classes instead of a few complex ones. Your solution shall have at least 5 different classes.
Your classes shall have well defined responsibilities. A poor solution would do output in most or all of the classes. A good solution confines output to one class. Think about how easy it would be to change your program if on Tuesday I require you to use a GUI instead of a text based interface.
The top level class of your program must be called
Game. It must have a constructor
that takes a
boolean is used for
testing purposes. If it is
true, then the secret code is revealed
throughout the game. The
Game class must also have a method
runGames that carries out the actual games. Your program must run correctly when
the main method of class MastermindDriver.java is called.
You must include a tester class, MasterMindTest.java Even though your testing code will not be executed you must include your testing code (in its own class) in your submission. On this assignment you can't share testing code because you are all doing your own design.
When finished turn in a jar file named A4.jar that contains all the .java files needed for your program to be compiled and run. Include all the source code for all the classes you created, plus Game.java, MastermindDriver.java, and MasterMindTester.java. (Don't turn in the .class files.) This is not an executable jar, simply an archive jar. Use the turnin program to turn the file in. jar is a program included in the standard edition of Java loaded on the computers in the Microlab and that you have on your computer if you downloaded Java. If you work with a partner turn in only a single version of the code. Do not turn in the jar to both accounts. Instead, pick one person's account and turn the file into that account only.
Checklist. Did you remember to:
ints, or possibly use the built in Java
Colorclass. For this assignment you should err on the side of having lots of simple classes instead of a few complex ones.
Back to the CS 314 homepage.