CSCI 1301: Introduction to Computing and Programming Spring 2018 Project 3: Hangman 2.0 (A Word Guessing Game)

Similar documents
Recommended Group Brainstorm (NO computers during this time)

Up Diagonal. Right. Question No. 1 (60 points)

CE151 ASSIGNMENT

CSCI 1301: Introduction to Computing and Programming Spring 2019 Lab 10 Classes and Methods

CSCI 1301: Introduction to Computing and Programming Summer 2018 Lab 07 Classes and Methods

Due Date: Two Program Demonstrations (Testing and Debugging): End of Lab

Hangman - Compsci 201

Evil Hangman Project

Assignment #3 Hangman Due: 11AM PST on Thursday, July 20th

EECS2031 Winter Software Tools. Assignment 1 (15%): Shell Programming

ASSIGNMENT 5 Objects, Files, and a Music Player

EECE.2160: ECE Application Programming

There are several files including the start of a unit test and the method stubs in MindNumber.java. Here is a preview of what you will do:

6.189 Project 1. Readings. What to hand in. Project 1: The Game of Hangman. Get caught up on all the readings from this week!

CSc 2310 Principles of Programming (Java) Jyoti Islam

CS 2110 Summer 2011: Assignment 2 Boggle

ASSIGNMENT 5 Objects, Files, and More Garage Management

CPSC 217 Assignment 3

Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time)

CIS 162 Project 4 Farkle (a dice game)

CSCI 1301: Introduction to Computing and Programming

CMSC 132: Object-Oriented Programming II. Administrivia

Hangman YEAH Hours. Thursday, February 14, 7:30 9:00PM Andrew Tierno

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

CMPSCI 187 / Spring 2015 Hangman

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

CSSE2002/7023 The University of Queensland

Part 1: Group Brainstorm (NO computers during this time) Part 2: Submit Individual Brainstorm (You can now use a computer)

CSE 143: Computer Programming II Summer 2015 HW6: 20 Questions (due Thursday, August 13, :30pm)

Lab 1 Implementing a Simon Says Game

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points

Introduction to the coursework for CI228

Tips from the experts: How to waste a lot of time on this assignment

Java Identifiers, Data Types & Variables

G52CPP Lab Exercise: Hangman Requirements (v1.0)

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

LAB 13: ARRAYS (ONE DIMINSION)

CS 142 Style Guide Grading and Details

Using C++, design an Abstract Data Type class named MyGrades. The class must have the following private members :

Introduction to Programming II Winter, 2015 Assignment 5 (Saturday, April 4, 2015: 23:59:59)

January 16 Do not hand in a listing of the file InvalidRowCol.java.

SPRING 2017 CSCI 304 LAB1 (Due on Feb-14, 11:59:59pm)

BRAZOSPORT COLLEGE LAKE JACKSON, TEXAS SYLLABUS COSC 1320: INTRODUCTION TO C++ PROGRAMMING COMPUTER TECHNOLOGY & OFFICE ADMINISTRATION DEPARTMENT

Regis University CC&IS CS362 Data Structures

Simple design exercise similar to what you will do for your CS102 project (and what happens in industry!) Stages:

Introduction to Computer Programming

Project 1: Implementation of the Stack ADT and Its Application

AP Computer Science Homework Set 5 2D Arrays

CSci 1113: Introduction to C/C++ Programming for Scientists and Engineers Homework 10 Spring 2018

CSE Theory of Computing Fall 2017 Project 1-SAT Solving

ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists

Lab 1 Implementing a Simon Says Game

Honors Computer Science Python Mr. Clausen Programs 4A, 4B, 4C, 4D, 4E, 4F

Lab Exercise 6: Abstract Classes and Interfaces CS 2334

CS ) PROGRAMMING ASSIGNMENT 11:00 PM 11:00 PM

Lab 1: Silver Dollar Game 1 CSCI 2101B Fall 2018

CS 1301 Exam 1 Fall 2010

Decision Logic: if, if else, switch, Boolean conditions and variables

Spring 2018 El Camino College E. Ambrosio. Course Syllabus

Lab 3 Process Scheduling Due date: 29-Nov-2018

CpSc 1111 Lab 5 Formatting and Flow Control

CS 211 Programming Practicum Fall 2018

Lab 03 - x86-64: atoi

Lab 4 - Lazy Deletion in BSTs

a f b e c d Figure 1 Figure 2 Figure 3

This homework has an opportunity for substantial extra credit, which is described at the end of this document.

1. Introduction. 2. Deliverables

Lab Exercise 4: Inheritance and Polymorphism CS 2334

Note : Your program must contain the following 6 functions :

Programming Assignment IV Due Thursday, November 18th, 2010 at 11:59 PM

CS2 Practical 1 CS2A 22/09/2004

EECS2031 Winter Software Tools. Assignment 2 (15%): C Programming

CSE 143: Computer Programming II Spring 2015 HW7: 20 Questions (due Thursday, May 28, :30pm)

Guessing Game with Objects

CS : Programming for Non-majors, Fall 2018 Programming Project #2: Census Due by 10:20am Wednesday September

Topics. Chapter 5. Equality Operators

Basic Operations jgrasp debugger Writing Programs & Checkstyle

CS2 Practical 2 CS2Ah

Deliverables. Problem Description

PIC 10B Lecture 1 Winter 2014 Homework Assignment #3

ITP489 In-Memory DBMS for Real Time Analytics

First Visual Basic Lab Paycheck-V1.0

Programming Assignment IV Due Thursday, June 1, 2017 at 11:59pm

The Linux Command Line: A Complete Introduction, 1 st ed., by William E. Shotts, Jr., No Starch Press, 2012.

CASPER COLLEGE COURSE SYLLABUS MSFT 1600 Managing Microsoft Exchange Server 2003 Semester/Year: Fall 2007

Read this before starting!

Java Outline (Upto Exam 2)

Assignment #4 Minesweeper

Programming Assignment I Due Thursday, October 7, 2010 at 11:59pm

Tips from the experts: How to waste a lot of time on this assignment

Note: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.

This is a combination of a programming assignment and ungraded exercises

MWF 9:00-9:50AM & 12:00-12:50PM (ET)

CMSC 201 Spring 2018 Project 3 Minesweeper

CpSc 1111 Lab 9 2-D Arrays

CS 111: Programming Fundamentals II

ENCE 3241 Data Lab. 60 points Due February 19, 2010, by 11:59 PM

CS3114 (Fall 2013) PROGRAMMING ASSIGNMENT #2 Due Tuesday, October 11:00 PM for 100 points Due Monday, October 11:00 PM for 10 point bonus

6.1 Skip List, Binary Search Tree

Transcription:

Introduction In this project, you are going to implement the word guessing game, Hangman 2.0. Your program is going to get a random word from an enumerated list (instructions below) and then let the user guess letters until they get the word correct, run out of guesses, or solve the word. A unique characteristic of Hangman 2.0 is that the user must specify a subset of the available spaces to check. So, for each guess, the user provides the letter to guess along with the spaces he/she wants to check. The game has three levels of difficulty. The difficulty level determines the number of spaces allowed to check on each guess along with the total number of guesses the user can make. At the easy difficulty level, the user is allowed 15 guesses and must specify 4 spaces to check per guess. Users playing at the intermediate difficulty level get 12 guesses and must specify 3 spaces. When the game is on the hard difficulty level, the user gets 10 guesses and must specify 2 spaces at a time. An incorrect guess (or solve attempt) causes the program to decrement the number of remaining guesses, but a correct guess does not affect the number of remaining guesses. Also, invalid input does not affect the number of remaining guesses. Write a Java program in a file called Hangman2.java that allows the user to play Hangman as many times as they wish as long as the user doesn t exceed 20 games (the maximum number of games the user can play that s how many items are in the word bank). When the program begins, it will ask for the difficulty level from the user. The program should read the user s input as a String, take the first letter from the string, and make sure that it is equal to e, i, or h. If the input is invalid, then a message is printed, and the user is re-prompted until the input is valid. The program then asks the user for their guess. At any point, the user can choose to solve the word instead of entering another level. If the user enters solve with any capitalization, a message should be printed allowing the user to solve the game. If this answer is incorrect, the number of guesses should be decremented and the user should be re-prompted to enter a letter. If the user correctly solves the word, the game should end. After the game ends, the program will print the result and ask the user if they want to play again. Many other scenarios are given in the examples below. Your program should behave the same way for all test cases given. You should also come up with additional test cases in order to thoroughly test your application. Page 1 of 8

Sample Output Each example has the output of a single run of a correctly working program. In these examples, testingmode is on, which means that you can see the secret word before guessing (see below for more details). This is very handy when debugging your code. The user s input in the examples is marked in green. Example 1 (User wins by guessing letters): eeeeeeeeee Please enter the letter you want to guess: d 0 1 2 5 The updated word is: -d-------- 0 1 5 7 The updated word is: id---i-i-- Please enter the letter you want to guess: e 2 3 8 9 The updated word is: ide--i-ie- Please enter the letter you want to guess: n 3 4 5 6 The updated word is: iden-i-ie- Please enter the letter you want to guess: t 3 4 5 6 The updated word is: identi-ie- Please enter the letter you want to guess: f 4 5 6 7 The updated word is: identifie- Page 2 of 8

Please enter the letter you want to guess: r 6 7 8 9 The updated word is: identifier You have guessed the word! Congratulations Would you like to play again? Yes(y) or No(n) y // execution continues for the next round Example 2 (Checking invalid input) f Invalid difficulty. Try Again... g Invalid difficulty. Try Again... e The word is: -------- Please enter the letter you want to guess: 7 Please enter the letter you want to guess: a 1 2 Please enter the letter you want to guess: a 1 2 3 Please enter the letter you want to guess: a 1 2 3 4 5 Please enter the letter you want to guess: b 1 5 9 12 //Execution continues from this point. Page 3 of 8

Example 3 (If two letters are entered as the guess, take the first one) e d 0 1 2 3 The updated word is: i--------- Please enter the letter you want to guess://execution continues beyond this point. Example 4 (If user makes an identical correct guess or a guess containing an already uncovered space, don t decrement guesses remaining) e 0 0 0 0 The updated word is: i--------- 0 1 2 3 The updated word is: i--------- 1 2 3 4 Guesses Remaining: 14 3 4 5 6 The updated word is: i----i---- Guesses Remaining: 14 Please enter the letter you want to guess: //Execution continues from this point Example 5 (Max guesses is exceeded, resulting in a player loss) h Page 4 of 8

Please enter the letter you want to guess: z 0 1 Guesses Remaining: 9 Please enter the letter you want to guess: z 1 2 Guesses Remaining: 8 Please enter the letter you want to guess: z 4 5 Guesses Remaining: 7 Please enter the letter you want to guess: q 0 3 Guesses Remaining: 6 Please enter the letter you want to guess: r 0 1 Guesses Remaining: 5 Please enter the letter you want to guess: z y Guesses Remaining: 5 Please enter the letter you want to guess: y 2 3 Guesses Remaining: 4 Please enter the letter you want to guess: h 4 5 Guesses Remaining: 3 Please enter the letter you want to guess: d 7 8 Guesses Remaining: 2 Please enter the letter you want to guess: u 0 3 Page 5 of 8

Guesses Remaining: 1 Please enter the letter you want to guess: a 3 4 Guesses Remaining: 0 You have failed to guess the word... :( Would you like to play again? Yes(y) or No(n) n Example 6 (Solving word) i 0 4 5 The updated word is: i----i---- Guesses Remaining: 12 Please enter the letter you want to guess: solve Please solve the answer: identical That is not the secret word. Guesses Remaining: 11 Please enter the letter you want to guess: d 0 1 2 The updated word is: id---i---- Guesses Remaining: 11 Please enter the letter you want to guess: solve Please solve the answer: identifier You win! You have guessed the word! Congratulations Would you like to play again? Yes(y) or No(n) n Requirements: You cannot use arrays or the StringBuilder class to implement this project. You can only work with the String methods discussed in lecture. You must use index 0 as the index of the first character in your word. For example, if the secret word is hardware, the letter h is at index 0. So, if the user specifies space 0, you should uncover the h. Failure to use correct indexing will have a negative impact on your assignment grade. Page 6 of 8

In order to facilitate the testing of your program, you must include a boolean variable called testingmode initialized to true in the top of your class (under the class declaration and above your main method) as shown below. private static final boolean testingmode = true; If the value of the variable testingmode is true, your program will display the secret word the user should guess. This helps you test your program and helps us grade your program. Without this variable, we will not know what the correct answer is. See example 1 to see the output. On the other hand, if the value of the variable testingmode is set to false, the program will not show the value of the secret word. When you submit your code, make sure the variable is set to true. Use the RandomWord.newWord() method to generate random words, and this method should only be called once per game, and it can be called at most 20 times in a single program run (note: after 20 calls, it issues an error message and terminates). This method is provided to you. However, you must download the RandomWord.java file from the labs and projects website, and place RandomWord.java in the same source directory as Hangman2.java. RandomWord.java randomly picks a word from an enumerated list and returns it when the the newword() method is called. If you are interested in how it works, you can look at the source code. Do not modify the source code in RandomWord.java. The code for this assignment will require loops, decision statements, variables, etc. Hints: You may want to use two Strings to store the secret word and the word that is displayed to the user. The secret word is stored internally (the user can t see it unless testingmode is set to true) and the display word is what they see on the screen. The display word will start out as a series of dashes ( - ) and then be modified after a correct guess. You may find the following methods useful: o Character.isLetter(char arg) returns true if the character arg is a letter o Character.isDigit(char arg) returns true if the character arg is a number o Character.getNumericValue(char arg) returns the numeric value of a character Additional Requirements: Page 7 of 8

You must make your program output look exactly like the examples above. Your program must use RandomWord.newWord() method in the provided RandomWord class. Failure to use this method may result in a failing grade. Also, your testingmode boolean variable must be set to true when you submit your final version. The name of the class in your java program must be Hangman2. Therefore, the java source code file must be called Hangman2.java. Your code must include a comment header like the following in every project you submit. /* * Hangman2.java * Author: [Your name here] * Submission Date: [Submission date here] * * Purpose: A brief paragraph description of the * program. What does it do? * * Statement of Academic Honesty: * * The following code represents my own work. I have neither * received nor given inappropriate assistance. I have not copied * or modified code from any source other than the course webpage * or the course textbook. I recognize that any unauthorized * assistance or plagiarism will be handled in accordance with * the University of Georgia's Academic Honesty Policy and the * policies of this course. I recognize that my work is based * on an assignment created by the Department of Computer * Science at the University of Georgia. Any publishing * or posting of source code for this project is strictly * prohibited unless you have written consent from the Department * of Computer Science at the University of Georgia. */ Project Submission Submit the file Hangman2.java and only that file via elc. Project Grading All projects are graded out of a possible 100 points. Programs can be submitted up to 48 hours late, but late points will be deducted per the syllabus. Programs not submitted within 48 hours after the deadline will receive a grade of zero. Programs that do not compile will receive a grade of zero. You must make absolutely certain your program compiles before submitting, and you must thoroughly test your program with different inputs to verify that it is working correctly. Your program must work with aforementioned RandomWord.java file; otherwise, your project may receive a failing grade. All instructions must be followed in order to receive full credit. Your program will be tested thoroughly to verify if it plays a series of word guessing runs correctly and follows the directions in the above description (especially the error handling cases). Page 8 of 8