首页 > > 详细

Project 3: GuessMe!

 Project 3: GuessMe!

Using Loops and Strings to Create a Game
Overview 1
Learning Goals: 1
Project Specification: Your Tasks: 2
Export and Submit 4
Style Guide: 6
Tips 7
Overview
For this project, we will explore how to work with looping, conditionals, and Strings in Java. With
looping and conditionals we can finally begin to write more interesting programs. For more
information on Strings in Java you can use zybooks or the link here. For looping, you can use
either zybooks or the link here.
For our project we will be using the JUnit testing framework. The tests have descriptions in the
GuessMeTest.java and the descriptions of what the tests are doing are contained within
each test. When you are done with the project, you will submit it to Gradescope.
Learning Goals:
● Work with multi-file Java projects
● Work with Strings and varied inputs
● Use loops to iterate through Strings
● Practice using the JGrasp debugger
● Work with methods and objects
● Run JUnit tests
● Use recommended style guide
1
Project Specification: Your Tasks:
In this project, we will be making and playing a game called GuessMe. The object of the game
is for the game to generate a random four-letter string consisting of ‘A’, ‘B’, ‘C’, and ‘D’, and for
us to guess the string! We only have a limited number of tries to guess the string, and only the
hints from our previous guesses (how many letters match) to help us. See a sample output
below:
2
These are the classes we give you:
1. GuessMe.java
2. GuessMeMain.java
3. GuessMeTest.java
You will be given the entire main method (the front end) and framework for the GuessMe class
(the back end). In the framework are instructions that detail more specifically what each part of
the project is supposed to do, so make sure to read them. Do not delete the starter code!
1. GuessMe.java
You will need to complete both constructors and write six methods:
play(), isOver(), isWin(), getRemainingGuesses(), reset, and the helper
method generateWord(). The details for each of these methods are listed extensively in the
starter code.
In addition you will also need to declare four instance variables which will be used in
your project:
● word, which is a String and will represent the randomly generated word,
● remainingGuesses, which is an int and will represent the number of guesses the
player has remaining, and
● wordFound, which is a boolean and will be true if the player correctly guesses the word
and false otherwise.
● rand, which is our random number generator which we will use for creating random
words.
3
When initializing these in the constructors, think about how to use helper methods to your
advantage.
2. GuessMeMain.java
This is the main file, which handles the front end. Do not change this file, as it is what is
responsible for printing the prompts and input handling.
3. GuessMeTest.java
This is the test file, which acts as a testing framework for your code. You don’t need to
understand everything going on in this file, but feel free to take a look if you have the time and
are curious. You may add tests if you like, but do so at your own risk. Do not modify the tests
we give you. You may find it useful to use these in conjunction with the debugger.
Export and Submit
Step 1: Export the File
When you have completed this project, you should export a file containing the entire Java
project. There are two ways to do this.
1- Click on the “jar” icon and the .zip file is created. See below for a visual guide.
OR:
2- Click on the Project menu in the package explorer. Then choose “Project -> Create JAR or
Zip file for Project” from the menu.
4
Check it is the correct project name (GuessMe.zip) in the “Zip file” box (as in the figure
below). Click on “Create Zip”.
Step 2: Submit the file in Gradescope
Now log into Gradescope, select the assignment, and submit the zip file for grading.
5
Compilation errors will be provided by the autograder for this assignment. You must read
assignments carefully -- if your submission is not passing a test, it is almost certainly because
your submission doesn't match the requirements of the assignment.
If all tests pass your screen should show a score of 150/150. You must check that the score is
not a 0. Read the FAQs in Moodle to fix the problem if the autograder shows a score of 0.
Check that you are not uploading the starter code!
Remember, you can re-submit the assignment as many times as you want, until the
deadline. If it turns out you missed something and your code doesn't pass 100% of the
tests, you can keep working until it does. Attend office hours for help or post your
questions in Piazza.
Style Guide:
Apart from the score of the autograder, your project will be manually graded for following
these style guidelines (10 points):
1. All unnecessary lines of code have been removed.
2. Optimal use of blank lines and indents and spaces for operators.
6
3. Use of camelCase for variable/parameter and method names.
4. Variables declared early (not within code), and initialized where appropriate and
practical.
5. Descriptive variable and method names.
See zyBooks sections 2.8 and 2.14 for the recommended style guidelines.
Tips
● Use your debugger! It is very useful in finding exactly where your program stops doing
what you want it to do.
● Start early! Projects are starting to get a little longer, so if you get stuck you need to
make sure you have enough time to seek help.
● Seek help when you get stuck. We have office hours and forums specifically for you to
ask questions when you need assistance. Use public posts as much as possible so we
don’t have to answer the same question multiple times, only use a private post if you
need us to see your code or have questions specific to you.
● Look at examples in both your textbook and previous labs. While you shouldn’t be
copying code, looking at examples can help clear up semantic or simple questions
should they come up.
● Submit to gradescope at least once, even if you aren’t completely done. There is a huge
difference between a 50% and a 0%. That said, aim for 100%.
See this link for FAQs for projects.
 
联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!