java
- You will be creating a small guessing game which consists of two classes, GameDriver and RandGuessGame.
- The game will randomly generate five numbers between 1 and 100, show the player only the first and last, and they must guess if the sum of all numbers is greater than 250.
- The GameDriver is provided for you, as is starter code for RandGuessGame. You must write the remainder of RandGuessGame to the provided specifications. Javadocs for these classes are in the starter project you will download from Web-CAT (providedDoc ‑> index.html). There is also a text file which provides some example output.
Lab2-Review-Starter/.classpath
Lab2-Review-Starter/.project
Lab2-Review-Starter
org.eclipse.jdt.core.javabuilder
org.eclipse.jdt.core.javanature
Lab2-Review-Starter/.settings/org.eclipse.jdt.core.prefs
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Lab2-Review-Starter/Example Output
EXAMPLE OUTPUT
Run 1: Player guesses correctly
54 X X X 83
Is the sum of the numbers greater than 250?
(Y or N): Y
You guessed correctly! The sum was 314!
54 3 77 97 83
Run 2: Player guesses incorrectly
78 X X X 37
Is the sum of the numbers greater than 250?
(Y or N): N
You guessed wrong! The sum was 305!
78 100 49 41 37
Run 3: Player provides incorrect input multiple times
97 X X X 92
Is the sum of the numbers greater than 250?
(Y or N): y
Is the sum of the numbers greater than 250?
(Y or N): n
Is the sum of the numbers greater than 250?
(Y or N): x
Is the sum of the numbers greater than 250?
(Y or N): #
Is the sum of the numbers greater than 250?
(Y or N): N
You guessed wrong! The sum was 339!
97 10 86 54 92
Lab2-Review-Starter/providedDoc/GameDriver.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Class
Next Class
Frames
No Frames
All Classes
Summary:
Nested |
Field |
Constr |
Method
Detail:
Field |
Constr |
Method
Class GameDriver
java.lang.Object
GameDriver
public class GameDriver
extends java.lang.Object
Runs the RandGuessGame. Creates an instance of RandGuessGame and calls upon its methods to conduct the game.
RandGuessGame methods called in order:
populateArray
outputArray (passing true to hide values)
playerGuess
getResult
outputArray (passing false to show all values)
Constructor Summary
Constructors Constructor and Description
GameDriver()
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description
static void
main(java.lang.String[] args)
Main method which creates instance of RandGuessGame and executes its methods.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
GameDriver
public GameDriver()
Method Detail
main
public static void main(java.lang.String[] args)
Main method which creates instance of RandGuessGame and executes its methods.
Parameters:
args – Command line arguments (Unused)
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Class
Next Class
Frames
No Frames
All Classes
Summary:
Nested |
Field |
Constr |
Method
Detail:
Field |
Constr |
Method
Lab2-Review-Starter/providedDoc/RandGuessGame.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Class
Next Class
Frames
No Frames
All Classes
Summary:
Nested |
Field |
Constr |
Method
Detail:
Field |
Constr |
Method
Class RandGuessGame
java.lang.Object
RandGuessGame
public class RandGuessGame
extends java.lang.Object
Class for a simple, randomized guessing game. Five integer values between 1 and MAX_VALUE (inclusive) will be
generated. Only the first and last will be shown to the player. The player must then guess if the sum
of all of the numbers is greater than the possible average or not.
Field Summary
Fields Modifier and Type Field and Description
private static int
ARR_SIZE
Number of randomly generated numbers.
private int
arraySum
Stores sum of random values.
private char
guess
Stores player’s guess.
private int
guessTarget
Number the player must guess against, calculated with MAX_VALUE and ARR_SIZE.
private boolean
hideMiddleVals
Determines if the String returned by toString hides the middle values.
private static int
MAX_VALUE
Maximum value of randomly generated values.
private int[]
numbers
Stores randomly generated numbers for game.
private java.util.Random
rand
Random number generator to use for the game.
Constructor Summary
Constructors Constructor and Description
RandGuessGame(java.util.Random randIn)
Constructor for the RandGuessGame.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description
int
getArraySum()
Retrieves the sum of the numbers in the array.
int[]
getNumbers()
Retrieves the numbers array.
java.lang.String
getResult()
Checks to see if player’s guess was correct, and constructs and returns a String that reports if they
are correct or incorrect, and appends the correct sum of the array.
void
populateArray()
Populates the “numbers” array with random numbers between 1 and “MAX_VALUE”.
void
toggleHidden()
Toggles the value of hideMiddleVals.
java.lang.String
toString()
Returns a String containing the values in the “numbers” array on a single line, separated by spaces
with the middle values hidden or all visible based on value of “hideMiddleValue” data member.
boolean
validatePlayerGuess(char guessIn)
Accepts a user’s guess for the game.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
MAX_VALUE
private static final int MAX_VALUE
Maximum value of randomly generated values.
See Also:
Constant Field Values
ARR_SIZE
private static final int ARR_SIZE
Number of randomly generated numbers.
See Also:
Constant Field Values
numbers
private int[] numbers
Stores randomly generated numbers for game.
guessTarget
private int guessTarget
Number the player must guess against, calculated with MAX_VALUE and ARR_SIZE.
guess
private char guess
Stores player’s guess.
arraySum
private int arraySum
Stores sum of random values.
hideMiddleVals
private boolean hideMiddleVals
Determines if the String returned by toString hides the middle values.
rand
private java.util.Random rand
Random number generator to use for the game.
Constructor Detail
RandGuessGame
public RandGuessGame(java.util.Random randIn)
Constructor for the RandGuessGame. Creates “numbers” array of size ARR_SIZE to store random values,
sets arraySum to zero, and calculates value of “guessTarget” by multiplying the amount of numbers by
half of “MAX_VALUE”. The passed Random object is assigned to the class’ Random member. hideMiddleVals
is defaulted to “true”.
Parameters:
randIn – The random number generator to be used for this instance of the game.
Method Detail
populateArray
public void populateArray()
Populates the “numbers” array with random numbers between 1 and “MAX_VALUE”.
toggleHidden
public void toggleHidden()
Toggles the value of hideMiddleVals. If it is currently true, sets it to false, and vice-versa.
toString
public java.lang.String toString()
Returns a String containing the values in the “numbers” array on a single line, separated by spaces
with the middle values hidden or all visible based on value of “hideMiddleValue” data member. There is
a trailing space on the end, so an example String returned may be: “5 X X X 67 “. NOTE: This does not
output to System.out, it generates and returns a String.
Overrides:
toString in class java.lang.Object
Returns:
A String with the values of the numbers array. Middle values are hidden if hideMiddleValue
is true.
validatePlayerGuess
public boolean validatePlayerGuess(char guessIn)
Accepts a user’s guess for the game. Validates that it is either the character ‘Y’ or ‘N’. If it
is a valid guess, sets the guess data member to the passed value and returns “true”. If it is not
valid it does not change the value of guess and returns false.
Parameters:
guessIn – The player’s guess.
Returns:
True if the passed guess is valid, false if it is not.
getResult
public java.lang.String getResult()
Checks to see if player’s guess was correct, and constructs and returns a String that reports if they
are correct or incorrect, and appends the correct sum of the array.
Returns:
A String reporting the results of the game.
getNumbers
public int[] getNumbers()
Retrieves the numbers array. Used for testing, do not change.
Returns:
The numbers array.
getArraySum
public int getArraySum()
Retrieves the sum of the numbers in the array. Used for testing, do not change.
Returns:
The value of arraySum.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Class
Next Class
Frames
No Frames
All Classes
Summary:
Nested |
Field |
Constr |
Method
Detail:
Field |
Constr |
Method
Lab2-Review-Starter/providedDoc/allclasses-frame.html
All Classes
GameDriver
RandGuessGame
Lab2-Review-Starter/providedDoc/allclasses-noframe.html
All Classes
GameDriver
RandGuessGame
Lab2-Review-Starter/providedDoc/class-use/GameDriver.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev
Next
Frames
No Frames
All Classes
Uses of Class
GameDriver
No usage of GameDriver
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev
Next
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/class-use/RandGuessGame.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev
Next
Frames
No Frames
All Classes
Uses of Class
RandGuessGame
No usage of RandGuessGame
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev
Next
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/constant-values.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev
Next
Frames
No Frames
All Classes
Constant Field Values
Contents
RandGuessGame
Modifier and Type Constant Field Value
private static final int
ARR_SIZE
5
private static final int
MAX_VALUE
100
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev
Next
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/deprecated-list.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev
Next
Frames
No Frames
All Classes
Deprecated API
Contents
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev
Next
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/help-doc.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev
Next
Frames
No Frames
All Classes
How This API Document Is Organized
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
Package
Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:
Interfaces (italic)
Classes
Enums
Exceptions
Errors
Annotation Types
Class/Interface
Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
Class inheritance diagram
Direct Subclasses
All Known Subinterfaces
All Known Implementing Classes
Class/interface declaration
Class/interface description
Nested Class Summary
Field Summary
Constructor Summary
Method Summary
Field Detail
Constructor Detail
Method Detail
Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
Annotation Type
Each annotation type has its own separate page with the following sections:
Annotation Type declaration
Annotation Type description
Required Element Summary
Optional Element Summary
Element Detail
Enum
Each enum has its own separate page with the following sections:
Enum declaration
Enum description
Enum Constant Summary
Enum Constant Detail
Use
Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the “Use” link in the navigation bar.
Tree (Class Hierarchy)
There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
When viewing the Overview page, clicking on “Tree” displays the hierarchy for all packages.
When viewing a particular package, class or interface page, clicking “Tree” displays the hierarchy for only that package.
Deprecated API
The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
Index
The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
Prev/Next
These links take you to the next or previous class, interface, package, or related page.
Frames/No Frames
These links show and hide the HTML frames. All pages are available with or without frames.
All Classes
The All Classes link shows all classes and interfaces except non-static nested types.
Serialized Form
Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking “Serialized Form” in the “See also” section of the class description.
Constant Field Values
The Constant Field Values page lists the static final fields and their values.
This help file applies to API documentation generated using the standard doclet.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev
Next
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/index-files/index-1.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
A G H M N P R T V
A
ARR_SIZE – Static variable in class RandGuessGame
Number of randomly generated numbers.
arraySum – Variable in class RandGuessGame
Stores sum of random values.
A G H M N P R T V
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/index-files/index-2.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
A G H M N P R T V
G
GameDriver – Class in
Runs the RandGuessGame.
GameDriver() – Constructor for class GameDriver
getArraySum() – Method in class RandGuessGame
Retrieves the sum of the numbers in the array.
getNumbers() – Method in class RandGuessGame
Retrieves the numbers array.
getResult() – Method in class RandGuessGame
Checks to see if player’s guess was correct, and constructs and returns a String that reports if they
are correct or incorrect, and appends the correct sum of the array.
guess – Variable in class RandGuessGame
Stores player’s guess.
guessTarget – Variable in class RandGuessGame
Number the player must guess against, calculated with MAX_VALUE and ARR_SIZE.
A G H M N P R T V
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/index-files/index-3.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
A G H M N P R T V
H
hideMiddleVals – Variable in class RandGuessGame
Determines if the String returned by toString hides the middle values.
A G H M N P R T V
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/index-files/index-4.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
A G H M N P R T V
M
main(String[]) – Static method in class GameDriver
Main method which creates instance of RandGuessGame and executes its methods.
MAX_VALUE – Static variable in class RandGuessGame
Maximum value of randomly generated values.
A G H M N P R T V
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/index-files/index-5.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
A G H M N P R T V
N
numbers – Variable in class RandGuessGame
Stores randomly generated numbers for game.
A G H M N P R T V
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/index-files/index-6.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
A G H M N P R T V
P
populateArray() – Method in class RandGuessGame
Populates the “numbers” array with random numbers between 1 and “MAX_VALUE”.
A G H M N P R T V
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/index-files/index-7.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
A G H M N P R T V
R
rand – Variable in class RandGuessGame
Random number generator to use for the game.
RandGuessGame – Class in
Class for a simple, randomized guessing game.
RandGuessGame(Random) – Constructor for class RandGuessGame
Constructor for the RandGuessGame.
A G H M N P R T V
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/index-files/index-8.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
A G H M N P R T V
T
toggleHidden() – Method in class RandGuessGame
Toggles the value of hideMiddleVals.
toString() – Method in class RandGuessGame
Returns a String containing the values in the “numbers” array on a single line, separated by spaces
with the middle values hidden or all visible based on value of “hideMiddleValue” data member.
A G H M N P R T V
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/index-files/index-9.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
A G H M N P R T V
V
validatePlayerGuess(char) – Method in class RandGuessGame
Accepts a user’s guess for the game.
A G H M N P R T V
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Letter
Next Letter
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/index.html
Lab2-Review-Starter/providedDoc/overview-tree.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev
Next
Frames
No Frames
All Classes
Hierarchy For All Packages
Class Hierarchy
java.lang.Object
GameDriver
RandGuessGame
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev
Next
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/package-frame.html
Classes
GameDriver
RandGuessGame
Lab2-Review-Starter/providedDoc/package-list
Lab2-Review-Starter/providedDoc/package-summary.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Package
Next Package
Frames
No Frames
All Classes
Package
Class Summary Class Description
GameDriver
Runs the RandGuessGame.
RandGuessGame
Class for a simple, randomized guessing game.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Package
Next Package
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/package-tree.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev
Next
Frames
No Frames
All Classes
Hierarchy For Package
Class Hierarchy
java.lang.Object
GameDriver
RandGuessGame
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev
Next
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/package-use.html
JavaScript is disabled on your browser.
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev
Next
Frames
No Frames
All Classes
Uses of Package
No usage of
Skip navigation links
Package
Class
Use
Tree
Deprecated
Index
Help
Prev
Next
Frames
No Frames
All Classes
Lab2-Review-Starter/providedDoc/script.js
function show(type)
{
count = 0;
for (var key in methods) {
var row = document.getElementById(key);
if ((methods[key] & type) != 0) {
row.style.display = ”;
row.className = (count++ % 2) ? rowColor : altColor;
}
else
row.style.display = ‘none’;
}
updateTabs(type);
}
function updateTabs(type)
{
for (var value in tabs) {
var sNode = document.getElementById(tabs[value][0]);
var spanNode = sNode.firstChild;
if (value == type) {
sNode.className = activeTableTab;
spanNode.innerHTML = tabs[value][1];
}
else {
sNode.className = tableTab;
spanNode.innerHTML = “” + tabs[value][1] + ““;
}
}
}
Lab2-Review-Starter/providedDoc/stylesheet.css
/* Javadoc style sheet */
/*
Overall document style
*/
@import url(‘resources/fonts/dejavu.css’);
body {
background-color:#ffffff;
color:#353833;
font-family:’DejaVu Sans’, Arial, Helvetica, sans-serif;
font-size:14px;
margin:0;
}
a:link, a:visited {
text-decoration:none;
color:#4A6782;
}
a:hover, a:focus {
text-decoration:none;
color:#bb7a2a;
}
a:active {
text-decoration:none;
color:#4A6782;
}
a[name] {
color:#353833;
}
a[name]:hover {
text-decoration:none;
color:#353833;
}
pre {
font-family:’DejaVu Sans Mono’, monospace;
font-size:14px;
}
h1 {
font-size:20px;
}
h2 {
font-size:18px;
}
h3 {
font-size:16px;
font-style:italic;
}
h4 {
font-size:13px;
}
h5 {
font-size:12px;
}
h6 {
font-size:11px;
}
ul {
list-style-type:disc;
}
code, tt {
font-family:’DejaVu Sans Mono’, monospace;
font-size:14px;
padding-top:4px;
margin-top:8px;
line-height:1.4em;
}
dt code {
font-family:’DejaVu Sans Mono’, monospace;
font-size:14px;
padding-top:4px;
}
table tr td dt code {
font-family:’DejaVu Sans Mono’, monospace;
font-size:14px;
vertical-align:top;
padding-top:4px;
}
sup {
font-size:8px;
}
/*
Document title and Copyright styles
*/
.clear {
clear:both;
height:0px;
overflow:hidden;
}
.aboutLanguage {
float:right;
padding:0px 21px;
font-size:11px;
z-index:200;
margin-top:-9px;
}
.legalCopy {
margin-left:.5em;
}
.bar a, .bar a:link, .bar a:visited, .bar a:active {
color:#FFFFFF;
text-decoration:none;
}
.bar a:hover, .bar a:focus {
color:#bb7a2a;
}
.tab {
background-color:#0066FF;
color:#ffffff;
padding:8px;
width:5em;
font-weight:bold;
}
/*
Navigation bar styles
*/
.bar {
background-color:#4D7A97;
color:#FFFFFF;
padding:.8em .5em .4em .8em;
height:auto;/*height:1.8em;*/
font-size:11px;
margin:0;
}
.topNav {
background-color:#4D7A97;
color:#FFFFFF;
float:left;
padding:0;
width:100%;
clear:right;
height:2.8em;
padding-top:10px;
overflow:hidden;
font-size:12px;
}
.bottomNav {
margin-top:10px;
background-color:#4D7A97;
color:#FFFFFF;
float:left;
padding:0;
width:100%;
clear:right;
height:2.8em;
padding-top:10px;
overflow:hidden;
font-size:12px;
}
.subNav {
background-color:#dee3e9;
float:left;
width:100%;
overflow:hidden;
font-size:12px;
}
.subNav div {
clear:left;
float:left;
padding:0 0 5px 6px;
text-transform:uppercase;
}
ul.navList, ul.subNavList {
float:left;
margin:0 25px 0 0;
padding:0;
}
ul.navList li{
list-style:none;
float:left;
padding: 5px 6px;
text-transform:uppercase;
}
ul.subNavList li{
list-style:none;
float:left;
}
.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited {
color:#FFFFFF;
text-decoration:none;
text-transform:uppercase;
}
.topNav a:hover, .bottomNav a:hover {
text-decoration:none;
color:#bb7a2a;
text-transform:uppercase;
}
.navBarCell1Rev {
background-color:#F8981D;
color:#253441;
margin: auto 5px;
}
.skipNav {
position:absolute;
top:auto;
left:-9999px;
overflow:hidden;
}
/*
Page header and footer styles
*/
.header, .footer {
clear:both;
margin:0 20px;
padding:5px 0 0 0;
}
.indexHeader {
margin:10px;
position:relative;
}
.indexHeader span{
margin-right:15px;
}
.indexHeader h1 {
font-size:13px;
}
.title {
color:#2c4557;
margin:10px 0;
}
.subTitle {
margin:5px 0 0 0;
}
.header ul {
margin:0 0 15px 0;
padding:0;
}
.footer ul {
margin:20px 0 5px 0;
}
.header ul li, .footer ul li {
list-style:none;
font-size:13px;
}
/*
Heading styles
*/
div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 {
background-color:#dee3e9;
border:1px solid #d0d9e0;
margin:0 0 6px -8px;
padding:7px 5px;
}
ul.blockList ul.blockList ul.blockList li.blockList h3 {
background-color:#dee3e9;
border:1px solid #d0d9e0;
margin:0 0 6px -8px;
padding:7px 5px;
}
ul.blockList ul.blockList li.blockList h3 {
padding:0;
margin:15px 0;
}
ul.blockList li.blockList h2 {
padding:0px 0 20px 0;
}
/*
Page layout container styles
*/
.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer {
clear:both;
padding:10px 20px;
position:relative;
}
.indexContainer {
margin:10px;
position:relative;
font-size:12px;
}
.indexContainer h2 {
font-size:13px;
padding:0 0 3px 0;
}
.indexContainer ul {
margin:0;
padding:0;
}
.indexContainer ul li {
list-style:none;
padding-top:2px;
}
.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt {
font-size:12px;
font-weight:bold;
margin:10px 0 0 0;
color:#4E4E4E;
}
.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd {
margin:5px 0 10px 0px;
font-size:14px;
font-family:’DejaVu Sans Mono’,monospace;
}
.serializedFormContainer dl.nameValue dt {
margin-left:1px;
font-size:1.1em;
display:inline;
font-weight:bold;
}
.serializedFormContainer dl.nameValue dd {
margin:0 0 0 1px;
font-size:1.1em;
display:inline;
}
/*
List styles
*/
ul.horizontal li {
display:inline;
font-size:0.9em;
}
ul.inheritance {
margin:0;
padding:0;
}
ul.inheritance li {
display:inline;
list-style:none;
}
ul.inheritance li ul.inheritance {
margin-left:15px;
padding-left:15px;
padding-top:1px;
}
ul.blockList, ul.blockListLast {
margin:10px 0 10px 0;
padding:0;
}
ul.blockList li.blockList, ul.blockListLast li.blockList {
list-style:none;
margin-bottom:15px;
line-height:1.4;
}
ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList {
padding:0px 20px 5px 10px;
border:1px solid #ededed;
background-color:#f8f8f8;
}
ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList {
padding:0 0 5px 8px;
background-color:#ffffff;
border:none;
}
ul.blockList ul.blockList ul.blockList ul.blockList li.blockList {
margin-left:0;
padding-left:0;
padding-bottom:15px;
border:none;
}
ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast {
list-style:none;
border-bottom:none;
padding-bottom:0;
}
table tr td dl, table tr td dl dt, table tr td dl dd {
margin-top:0;
margin-bottom:1px;
}
/*
Table styles
*/
.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary {
width:100%;
border-left:1px solid #EEE;
border-right:1px solid #EEE;
border-bottom:1px solid #EEE;
}
.overviewSummary, .memberSummary {
padding:0px;
}
.overviewSummary caption, .memberSummary caption, .typeSummary caption,
.useSummary caption, .constantsSummary caption, .deprecatedSummary caption {
position:relative;
text-align:left;
background-repeat:no-repeat;
color:#253441;
font-weight:bold;
clear:none;
overflow:hidden;
padding:0px;
padding-top:10px;
padding-left:1px;
margin:0px;
white-space:pre;
}
.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link,
.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link,
.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover,
.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover,
.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active,
.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active,
.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited,
.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited {
color:#FFFFFF;
}
.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span,
.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span {
white-space:nowrap;
padding-top:5px;
padding-left:12px;
padding-right:12px;
padding-bottom:7px;
display:inline-block;
float:left;
background-color:#F8981D;
border: none;
height:16px;
}
.memberSummary caption span.activeTableTab span {
white-space:nowrap;
padding-top:5px;
padding-left:12px;
padding-right:12px;
margin-right:3px;
display:inline-block;
float:left;
background-color:#F8981D;
height:16px;
}
.memberSummary caption span.tableTab span {
white-space:nowrap;
padding-top:5px;
padding-left:12px;
padding-right:12px;
margin-right:3px;
display:inline-block;
float:left;
background-color:#4D7A97;
height:16px;
}
.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab {
padding-top:0px;
padding-left:0px;
padding-right:0px;
background-image:none;
float:none;
display:inline;
}
.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd,
.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd {
display:none;
width:5px;
position:relative;
float:left;
background-color:#F8981D;
}
.memberSummary .activeTableTab .tabEnd {
display:none;
width:5px;
margin-right:3px;
position:relative;
float:left;
background-color:#F8981D;
}
.memberSummary .tableTab .tabEnd {
display:none;
width:5px;
margin-right:3px;
position:relative;
background-color:#4D7A97;
float:left;
}
.overviewSummary td, .memberSummary td, .typeSummary td,
.useSummary td, .constantsSummary td, .deprecatedSummary td {
text-align:left;
padding:0px 0px 12px 10px;
width:100%;
}
th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th,
td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{
vertical-align:top;
padding-right:0px;
padding-top:8px;
padding-bottom:3px;
}
th.colFirst, th.colLast, th.colOne, .constantsSummary th {
background:#dee3e9;
text-align:left;
padding:8px 3px 3px 7px;
}
td.colFirst, th.colFirst {
white-space:nowrap;
font-size:13px;
}
td.colLast, th.colLast {
font-size:13px;
}
td.colOne, th.colOne {
font-size:13px;
}
.overviewSummary td.colFirst, .overviewSummary th.colFirst,
.overviewSummary td.colOne, .overviewSummary th.colOne,
.memberSummary td.colFirst, .memberSummary th.colFirst,
.memberSummary td.colOne, .memberSummary th.colOne,
.typeSummary td.colFirst{
width:25%;
vertical-align:top;
}
td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover {
font-weight:bold;
}
.tableSubHeadingColor {
background-color:#EEEEFF;
}
.altColor {
background-color:#FFFFFF;
}
.rowColor {
background-color:#EEEEEF;
}
/*
Content styles
*/
.description pre {
margin-top:0;
}
.deprecatedContent {
margin:0;
padding:10px 0;
}
Summary {
padding:0;
}
ul.blockList ul.blockList ul.blockList li.blockList h3 {
font-style:normal;
}
div.block {
font-size:14px;
font-family:’DejaVu Serif’, Georgia, “Times New Roman”, Times, serif;
}
td.colLast div {
padding-top:0px;
}
td.colLast a {
padding-bottom:3px;
}
/*
Formatting effect styles
*/
.sourceLineNo {
color:green;
padding:0 30px 0 0;
}
h1.hidden {
visibility:hidden;
overflow:hidden;
font-size:10px;
}
.block {
display:block;
margin:3px 10px 2px 0px;
color:#474747;
}
.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink,
.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel,
.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink {
font-weight:bold;
}
.deprecationComment, .emphasizedPhrase, .interfaceName {
font-style:italic;
}
div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase,
div.block div.block span.interfaceName {
font-style:normal;
}
div.contentContainer ul.blockList li.blockList h2{
padding-bottom:0px;
}
Lab2-Review-Starter/src/GameDriver.java
Lab2-Review-Starter/src/GameDriver.java
import
java
.
util
.
Random
;
import
java
.
util
.
Scanner
;
/**
*
* Runs the RandGuessGame. Creates an instance of RandGuessGame and calls upon its methods to conduct the game.
*
RandGuessGame methods called in order:
* populateArray
* outputArray (passing true to hide values)
* playerGuess
* getResult
* outputArray (passing false to show all values)
*
*/
public
class
GameDriver
{
/**
* Main method which creates instance of RandGuessGame and executes its methods.
*
@param
args Command line arguments (Unused)
*/
public
static
void
main
(
String
[]
args
)
{
//Generate instance of game
RandGuessGame
game
=
new
RandGuessGame
(
new
Random
());
Scanner
input
=
new
Scanner
(
System
.
in
);
char
guess
;
//Conduct game behaviors
game
.
populateArray
();
System
.
out
.
println
(
game
);
do
{
System
.
out
.
print
(
“Is the sum of the numbers greater than 250?\n(Y or N): ”
);
guess
=
input
.
next
().
charAt
(
0
);
}
while
(
!
game
.
validatePlayerGuess
(
guess
));
System
.
out
.
println
(
game
.
getResult
());
game
.
toggleHidden
();
System
.
out
.
println
(
game
);
input
.
close
();
}
}
Lab2-Review-Starter/src/RandGuessGame.java
Lab2-Review-Starter/src/RandGuessGame.java
import
java
.
util
.
Random
;
/**
* Class for a simple, randomized guessing game. Five integer values between 1 and MAX_VALUE (inclusive) will be
* generated. Only the first and last will be shown to the player. The player must then guess if the sum
* of all of the numbers is greater than the possible average or not.
*
*/
public
class
RandGuessGame
{
//Declare data members
//Create Constructor
//Write member methods
/**
* Retrieves the numbers array. Used for testing, do not change.
*
@return
The numbers array.
*/
public
int
[]
getNumbers
()
{
return
numbers
;
}
/**
* Retrieves the sum of the numbers in the array. Used for testing, do not change.
*
@return
The value of arraySum.
*/
public
int
getArraySum
()
{
return
arraySum
;
}
}