Tags:
tag this topic
create new tag
view all tags
---+Mastermind with arrays: Fall 2025 ---++ Learning Objective(s) * Learn to use simple array ---++ Overview of the Program Modify the previous program so that it uses arrays instead of strings ---++ Specifics * The program is to be called <b>MasterMindArrays</b>. * There is no file i/o for this program. * You need to use at least two constants: One for the number of different "color" options per peg and another for the number of pegs. * The player is allowed to continue to guess until they get the right answer. * The program should continue to allow the player to play multiple games until they respond "n" to the question asking if they wish to continue. * The program should use arrays to store the solution and guesses. * The different colors are represented by single digits (at most from 0 - 9) * The program should have the following methods (beside the main): * <b>playGame</b> (that is sent the keyboard) which plays one instance of a complete game * <b>makeSolution</b> (which is sent the number of different possible colors and the number of pegs) and returns a random valid string representing the solution * <b>getGuess</b> (that is sent the keyboard) and returns a single guess. Because this is a complex program, error checking is not needed this time. * <b>getNumPerfect</b> (that is sent the solution and the guess) that returns the number of "perfect pegs" (same position and same color). For example: 1212 and 1231 would return 2. * <b>countLetter</b> (that is sent a letter which will typically be a digit and a string) that returns the number of times that digit occurs in the string. For example: 4 and 13445 would return 4. * <b>getNumClose</b> (that is sent the solution and the guess) that returns the number of shared colors that are not in the right position. * a <b>min</b> method (that is sent two integers and returns the smaller one) would be helpful. * you may use the solution from the previous lab ---++ Sample dialogue Below is a sample dialogue. <pre> What is your guess? <b><font color="blue">1224</font></b> There are 0 exactly right and 3 in the wrong spot. What is your guess? <b><font color="blue">4112</font></b> There are 3 exactly right and 0 in the wrong spot. What is your guess? <b><font color="blue">4132</font></b> There are 2 exactly right and 2 in the wrong spot. What is your guess? <b><font color="blue">4312</font></b> You got it right in 4 turns. Do you wish to play again (y or n)? <b><font color="blue">n</font></b> </pre> You can also run a solution for this program if you want. See classroom instructions for more details. ---++Lab Hints * Use the hints from last weekend ---++ Submission * Create a software development report * For the system design, you need to make your own flowchart. * For testing report, * make sure your tests ensure that each statement is executed at least one. * your <b>expected output</b> <font color="red">CANNOT</font> be pasted from the dialogue of a running. Only the actual output may be pasted * It should contain at least one different input that is an "error" * For the improvement section, specify how many points were lost from the last lab that you should not lose points for on this lab because you corrected the problem * create a pdf document from your software development report * create an empty zip folder * place *only* !MasterMind.java and your pdf document into it * submit the zip folder on canvas ---++ Optional improvements Optional improvements should ONLY be worked on once the program is completing working. In addition, the work is to be done on your own with little if any help for lab assistants or the instructor. 1. Only allow the user to enter a valid guess (correct number of pegs and allowed colors) 1. Output the number of guesses it took to get the right answer. At the end of the program, output the average number of guesses over all the games played. 1. Submission instructions a. Call this program <b>MasterMindArrays2</b> add it to the zip folder that contains the original solution. Be sure to include appropriate testing data in your sdr for your extra credit
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r1 - 2025-08-05
-
CathyBareiss
Home
Site map
Assessment web
BethelAIResources2026 web
CenterForComputing web
ChatGPT web
Intro2AIatBethel web
Main web
Sandbox web
TWiki web
CenterForComputing Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
E
dit
A
ttach
Copyright © 2008-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback