Inheritance in Java
Please read Assignment x
attached are all the files in a zip and a makefile
Files to Submit:
- Armour.java -your version of the Armour ADT.
- Consumable.java – your version of the Consumable ADT.
Note: This assignment is not written using purely idiomatic Java. It is written as a bridge–transition–between Java and C++.
The next (and last) assignment will add the
Tool class and address the non-idiomatic code
1 The Problem
This assignment deals with a program that places items into separate invent
or
ies. In this assignment, you will once again make use of inheritance–e.g., virtual functions. This time… in Java.
You will complete the Armour and Consumable classes.
1.1 Input
The program reads data from one file, items-0x.txt. Each line in this file represents one item. The first item on every line denotes the Item type–the remainder of the line varies by item type.
Tool Pickaxe Diamond 100 1 Fortune 5
Potion Speed-II-Potion Spd*2 1
Food Tomato Hunger-10 2
Tool Axe Stone 10 2 Unbreaking 2
Armour Boots Diamond 100 10 Protection 3 lightning
Each Item type is denoted by a keyword:
· Tool indicates a Tool object.
· Armour and Armor indicate an Armour object.
· Food, Potion, and Disposable indicate a Consumable object.
After the leading keywords, each line has a distinct structure:
1. The remainder of a Tool line contains–in order–a name, material, durability, speed, enchantment, and enchantment level. Tool Items are not stackable.
2. The remainder of a Armour line contains–in order–a name, material, durability, defense, enchantment, enchantment level, and element. Armour Items are not stackable.
3. The remainder of a Consumable line contains–in order–a name, effect, and # uses. Consumable Items are stackable.
1.2 Input
The program reads data from one file, items-0x.txt. Each line in this file represents one item. The first item on every line denotes the Item type–the remainder of the line varies by item type.
Tool Pickaxe Diamond 100 1 Fortune 5
Potion Speed-II-Potion Spd*2 1
Food Tomato Hunger-10 2
Tool Axe Stone 10 2 Unbreaking 2
Armour Boots Diamond 100 10 Protection 3 lightning
Each Item type is denoted by a keyword:
· Tool indicates a Tool object.
· Armour and Armor indicate an Armour object.
· Food, Potion, and Disposable indicate a Consumable object.
After the leading keywords, each line has a distinct structure:
1. The remainder of a Tool line contains–in order–a name, material, durability, speed, modifier, and modifier level. Tool Items are not stackable.
2. The remainder of a Armour line contains–in order–a name, material, durability, defense, modifier, modifier level, and element. Armour Items are not stackable.
3. The remainder of a Consumable line contains–in order–a name, effect, and # uses. Consumable Items are stackable.
In each of the above classes, you will need to:
1. Set the stackable attribute–i.e., super.stackable. The attribute, stackable, is a private data member of Item.
2. Set the name attribute–i.e., super.name. The attribute, name, is a protected data member of Item.
1.3 Output
If the program is run with the first provided input file, items-01.txt, the following output should be generated:
Processing Log:
(S) Speed-II-Potion
(S) Tomato
(S) PotatoCamera
(S) PotatoCamera
(S) Boots
(S) Boots
Player Storage Summary:
-Used 50% of 10 slots
Nme: Speed-II-Potion
Eft: Spd*2
Use: 1
Qty: 1
Nme: Tomato
Eft: Hunger-10
Use: 2
Qty: 1
Nme: PotatoCamera
Eft: ImageQuality-97%
Use: 5
Qty: 2
Nme: Boots
Dur: 100
Def: 10
Mtl: Diamond
Mdr: Protection (Lvl 3)
Emt: lightning
Nme: Boots
Dur: 100
Def: 10
Mtl: Diamond
Mdr: FeatherFalling (Lvl 4)
Emt: lightning
Note how there is no Tool output. The Tool class is not present in this assignment. The Tool class will be part of a future assignment.
Your output–including labels and spacing–must match the expected output.
1.4 Your Tasks
The key abstractions employed in this program are Inventory Item, ItemStack, Tool, Armour, and Consumable.
Do not change the packages. The package must remain package edu.odu.cs.cs330.items; for Tool, Armour, and Consumable. Changing the package is an automatic fail. Is this strict? Absolutely. However, I am explicitly instructing you to use this package.
Your task is to finish the Armour and Consumable ADTs:
1. Complete the Default Constructor for each class.
2. Complete the Copy Constructor for each class.
3. Complete the clone method for each class.
4. Complete the read method in each class.
5. Complete the toString method in each class.
Note that I have provided stubs for each of these functions (i.e., the code will compile). However, until you complete these functions, the code will not generate meaningful output.
You are expected to generate additional input files to test your code. Test your code throughly before submitting your solution.
2 Compiling Java
The easiest way to compile this assignment is to use the ./gradlew command on one of our Linux servers. After that, you will have a number of options for executing the code.
If you are installing Java on your own machine, you will need Java 16 or earlier.
As an alternative way to compile your code, you might want to install the Oracle Java compiler and an IDE on your own PC. Eclipse is a recommended platform–
2.1 Compiling and Running the Java Program
If the sample data above is kept in items-01.txt, to run this program, type:
./gradlew jar
java -jar build/libs/Storage.jar src/main/resources/items-01.txt 10
or
./gradlew run
The latter command executes the run target in the Gradle buildfile (which runs the necessary commands for you). This allows us to use fewer keystrokes (which are expensive).
Run the compiled solution with both the provided input file and your own test input files.
Once you have completed your solution, compare the output generated by your solution to the output generated by my solution. The two sets must be identical.
2.2 Compiling and Running the Tests
You should probably run the tests on a Linux machine… You can compile and run the test drivers (TestArmour and TestConsumable) with
./gradlew test
If you implemented everything in Armour and Consumable correctly you will see:
edu.odu.cs.cs330.items.TestConsumable > testClone PASSED
edu.odu.cs.cs330.items.TestConsumable > testCopyConstructor PASSED
edu.odu.cs.cs330.items.TestConsumable > testDefaultConstructor PASSED
edu.odu.cs.cs330.items.TestConsumable > testRead PASSED
edu.odu.cs.cs330.items.TestConsumable > testToString PASSED
edu.odu.cs.cs330.items.TestArmour > testClone PASSED
edu.odu.cs.cs330.items.TestArmour > testCopyConstructor PASSED
edu.odu.cs.cs330.items.TestArmour > testDefaultConstructor PASSED
edu.odu.cs.cs330.items.TestArmour > testRead PASSED
edu.odu.cs.cs330.items.TestArmour > testToString PASSED
in your output. Note that you may see quite a few blank lines in the test summary–I omitted them here for brevity.
If you see FAILED you must revisit revisit the corresponding function(s). There is a mistake in your code.
You may need to run
./gradlew clean test
to force a full recompile after making small updates.
2.3 IDEs and Command Line Arguments
(On a Windows system, you would omit the “./”. If you are running from Code::Blocks or a similar development environment, you may need to review how to
supply command-line parameters
to a running program.) Note that Eclipse provides the option to configure command line arguments.
3 Files
All files for this assignment are in a single zip file inventory_java_1.zip. Extra the contents of this zip file. Do not rename or move any of the files. The directory structure is important.
If you are are using Eclipse, run ./gradlew eclipse from your command prompt, powershell, or terminal (depending on your OS). This command will generate a .project file you can import into Eclipse.
4 Grading
Do not change the packages. The package must remain package edu.odu.cs.cs330.items; for Armour and Consumable. Changing the package is an automatic fail. Is this strict? Absolutely. However, I am explicitly instructing you to use this package.
In the grade report that you receive, you will see tests numbered 000 through 010.
1. Test 000 evaluates your implementation of Armour.Armour()
2. Test 001 evaluates your implementation of Armour.Armour(Armour src)
3. Test 002 evaluates your implementation of Armour.clone
4. Test 003 evaluates your implementation of Armour.toString
5. Test 004 evaluates your implementation of Armour.read
6. Test 005 evaluates your implementation of Consumable.Consumable()
7. Test 006 evaluates your implementation of Consumable.Consumable(Consumable src)
8. Test 007 evaluates your implementation of Consumable.clone
9. Test 008 evaluates your implementation of Consumable.toString
10. Test 009 evaluates your implementation of Consumable.read
11. Test 010 (System Tests) evaluate all both classes–i.e., your solution as a whole–including output and output formatting.
Do not procrastinate.
5 Submitting
Files to Submit:
· Armour.java–i.e., your version of the Armour ADT.
· Consumable.java–i.e., your version of the Consumable ADT.
gradlew
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG=”$0″
# Need this for relative symlinks.
while [ -h “$PRG” ] ; do
ls=`ls -ld “$PRG”`
link=`expr “$ls” : ‘.*-> \(.*\)$’`
if expr “$link” : ‘/.*’ > /dev/null; then
PRG=”$link”
else
PRG=`dirname “$PRG”`”/$link”
fi
done
SAVED=”`pwd`”
cd “`dirname \”$PRG\”`/” >/dev/null
APP_HOME=”`pwd -P`”
cd “$SAVED” >/dev/null
APP_NAME=”Gradle”
APP_BASE_NAME=`basename “$0″`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=””
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=”maximum”
warn ( ) {
echo “$*”
}
die ( ) {
echo
echo “$*”
echo
exit 1
}
# OS specific support (must be ‘true’ or ‘false’).
cygwin=false
msys=false
darwin=false
nonstop=false
case “`uname`” in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n “$JAVA_HOME” ] ; then
if [ -x “$JAVA_HOME/jre/sh/java” ] ; then
# IBM’s JDK on AIX uses strange locations for the executables
JAVACMD=”$JAVA_HOME/jre/sh/java”
else
JAVACMD=”$JAVA_HOME/bin/java”
fi
if [ ! -x “$JAVACMD” ] ; then
die “ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.”
fi
else
JAVACMD=”java”
which java >/dev/null 2>&1 || die “ERROR: JAVA_HOME is not set and no ‘java’ command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.”
fi
# Increase the maximum file descriptors if we can.
if [ “$cygwin” = “false” -a “$darwin” = “false” -a “$nonstop” = “false” ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ “$MAX_FD” = “maximum” -o “$MAX_FD” = “max” ] ; then
MAX_FD=”$MAX_FD_LIMIT”
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn “Could not set maximum file descriptor limit: $MAX_FD”
fi
else
warn “Could not query maximum file descriptor limit: $MAX_FD_LIMIT”
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS=”$GRADLE_OPTS \”-Xdock:name=$APP_NAME\” \”-Xdock:icon=$APP_HOME/media/gradle.icns\””
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath –path –mixed “$APP_HOME”`
CLASSPATH=`cygpath –path –mixed “$CLASSPATH”`
JAVACMD=`cygpath –unix “$JAVACMD”`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=””
for dir in $ROOTDIRSRAW ; do
ROOTDIRS=”$ROOTDIRS$SEP$dir”
SEP=”|”
done
OURCYGPATTERN=”(^($ROOTDIRS))”
# Add a user-defined pattern to the cygpath arguments
if [ “$GRADLE_CYGPATTERN” != “” ] ; then
OURCYGPATTERN=”$OURCYGPATTERN|($GRADLE_CYGPATTERN)”
fi
# Now convert the arguments – kludge to limit ourselves to /bin/sh
i=0
for arg in “$@” ; do
CHECK=`echo “$arg”|egrep -c “$OURCYGPATTERN” -`
CHECK2=`echo “$arg”|egrep -c “^-“` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath –path –ignore –mixed “$arg”`
else
eval `echo args$i`=”\”$arg\””
fi
i=$((i+1))
done
case $i in
(0) set — ;;
(1) set — “$args0” ;;
(2) set — “$args0” “$args1” ;;
(3) set — “$args0” “$args1” “$args2” ;;
(4) set — “$args0” “$args1” “$args2” “$args3” ;;
(5) set — “$args0” “$args1” “$args2” “$args3” “$args4” ;;
(6) set — “$args0” “$args1” “$args2” “$args3” “$args4” “$args5” ;;
(7) set — “$args0” “$args1” “$args2” “$args3” “$args4” “$args5” “$args6” ;;
(8) set — “$args0” “$args1” “$args2” “$args3” “$args4” “$args5” “$args6” “$args7” ;;
(9) set — “$args0” “$args1” “$args2” “$args3” “$args4” “$args5” “$args6” “$args7” “$args8” ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=(“$@”)
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]=”-Dorg.gradle.appname=$APP_BASE_NAME”
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [[ “$(uname)” == “Darwin” ]] && [[ “$HOME” == “$PWD” ]]; then
cd “$(dirname “$0″)”
fi
exec “$JAVACMD” “${JVM_OPTS[@]}” -classpath “$CLASSPATH” org.gradle.wrapper.GradleWrapperMain “$@”
gradlew.bat
@if “%DEBUG%” == “” @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if “%OS%”==”Windows_NT” setlocal
set DIRNAME=%~dp0
if “%DIRNAME%” == “” set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if “%ERRORLEVEL%” == “0” goto init
echo.
echo ERROR: JAVA_HOME is not set and no ‘java’ command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:”=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist “%JAVA_EXE%” goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not “%OS%” == “Windows_NT” goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if “x%~1” == “x” goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
“%JAVA_EXE%” %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% “-Dorg.gradle.appname=%APP_BASE_NAME%” -classpath “%CLASSPATH%” org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if “%ERRORLEVEL%”==”0” goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not “” == “%GRADLE_EXIT_CONSOLE%” exit 1
exit /b 1
:mainEnd
if “%OS%”==”Windows_NT” endlocal
:omega
src/main/java/edu/odu/cs/cs330/Storage.java
src/main/java/edu/odu/cs/cs330/Storage.java
package
edu
.
odu
.
cs
.
cs330
;
import
java
.
io
.
FileReader
;
import
java
.
io
.
BufferedReader
;
import
java
.
io
.
IOException
;
import
java
.
util
.
Scanner
;
import
edu
.
odu
.
cs
.
cs330
.
items
.
*
;
public
class
Storage
{
/**
* This is the first Java Assignment, Item Storage in Java.
*
*
@param
argv[1] items filename
*
@param
argv[2] inventories filename
*/
public
static
void
main
(
String
[]
argv
)
{
BufferedReader
infile
=
null
;
Inventory
inv
=
null
;
int
invSize
=
10
;
if
(
argv
.
length
<
1
)
{
System
.
err
.
println
(
"Usage: java -jar Storage.jar items-file"
);
System
.
exit
(
1
);
}
// If an inventory size was specified, parse it.
try
{
invSize
=
Integer
.
parseInt
(
argv
[
1
]);
}
catch
(
IndexOutOfBoundsException
e
)
{
// pass
invSize
=
10
;
//default to 10
}
catch
(
NumberFormatException
e
)
{
System
.
err
.
println
(
"Inventory size must be an integer"
);
System
.
exit
(
2
);
}
// Default to 10 if invSize is invalid--i.e., <= 0
if
(
invSize
<
1
)
{
invSize
=
10
;
}
try
{
infile
=
new
BufferedReader
(
new
FileReader
(
argv
[
0
]));
inv
=
createInventory
(
infile
,
invSize
);
infile
.
close
();
}
catch
(
IOException
e
)
{
System
.
err
.
println
(
"Error: "
+
argv
[
0
]
+
" could not be opened or read"
);
System
.
exit
(
3
);
}
// Print the Inventory
printInventorySummary
(
inv
);
}
/**
* Read an input stream and generate an Inventory.
*
*
@param
ins source from which to read Items
*
@param
size desired number of Inventory slots
*
*
@return
initialized Inventory
*
*
@throws
IOException if an input error occurs
*/
public
static
Inventory
createInventory
(
BufferedReader
ins
,
int
size
)
throws
IOException
{
Scanner
scanner
=
new
Scanner
(
ins
);
Inventory
inventory
=
new
Inventory
(
size
);
System
.
out
.
println
(
"Processing Log:"
);
while
(
scanner
.
hasNext
())
{
Item
item
=
ItemFactory
.
parseItemLine
(
scanner
);
if
(
item
!=
null
)
{
boolean
success
=
inventory
.
addItems
(
new
ItemStack
(
item
));
if
(
success
)
{
System
.
out
.
println
(
" (S) "
+
item
.
getName
());
}
else
{
System
.
out
.
println
(
" (D) "
+
item
.
getName
());
}
}
}
System
.
out
.
println
();
return
inventory
;
}
/**
* Print the final Inventory summary.
*
*
@param
inv Inventory to print
*/
public
static
void
printInventorySummary
(
Inventory
inv
)
{
System
.
out
.
println
(
"Player Storage Summary:"
);
System
.
out
.
println
(
inv
);
}
}
src/main/java/edu/odu/cs/cs330/items/Armour.java
src/main/java/edu/odu/cs/cs330/items/Armour.java
package
edu
.
odu
.
cs
.
cs330
.
items
;
import
java
.
util
.
Scanner
;
/**
* This class represents one piece of armour--as found in most video games.
* This includes boots and helmets.
*
* Armour may not be stacked. All Constructors must initialize Item::stackable
* to false.
*/
public
class
Armour
extends
Item
{
protected
int
durability
;
///< decreases each time the armour is used
protected
int
defense
;
///< damage that is blocked
protected
String
material
;
///< material out of which the armour is composed
protected
String
modifier
;
///< one of protection, feather_falling, or unbreaking
protected
int
modiferLevel
;
///< modifier level in the range 1 to 3
protected
String
element
;
///< associated element--e.g., ice, fire, and lightning.
/**
* Default to a armour with an empty name.
*/
public
Armour
()
{
// Make the necessary call to super(...)
this
.
durability
=
0
;
this
.
defense
=
0
;
this
.
material
=
""
;
this
.
modifier
=
""
;
this
.
modiferLevel
=
1
;
this
.
element
=
""
;
}
/**
* This is the Copy Constructor.
*/
public
Armour
(
Armour
src
)
{
// Make the necessary call to super(...)
this
.
durability
=
src
.
durability
;
this
.
defense
=
src
.
defense
;
this
.
material
=
src
.
material
;
this
.
modifier
=
src
.
modifier
;
this
.
modiferLevel
=
src
.
modiferLevel
;
this
.
element
=
src
.
element
;
}
/**
* Retrieve armour durability.
*/
public
int
getDurability
()
{
return
this
.
durability
;
}
/**
* Set armour durability.
*/
public
void
setDurability
(
int
durability
)
{
this
.
durability
=
durability
;
}
/**
* Retrieve armour defense.
*/
public
int
getDefense
()
{
return
this
.
defense
;
}
/**
* Set armour defense.
*/
public
void
setDefense
(
int
defense
)
{
this
.
defense
=
defense
;
}
/**
* Retrieve armour Material.
*/
public
String
getMaterial
()
{
return
this
.
material
;
}
/**
* Set armour Material.
*/
public
void
setMaterial
(
String
m
)
{
this
.
material
=
m
;
}
/**
* Retrieve armour Modifier.
*/
public
String
getModifier
()
{
return
this
.
modifier
;
}
/**
* Set armour Modifier.
*/
public
void
setModifier
(
String
m
)
{
this
.
modifier
=
m
;
}
/**
* Retrieve armour Modifier Level.
*/
public
int
getModifierLevel
()
{
return
this
.
modiferLevel
;
}
/**
* Set armour Modifier Level.
*/
public
void
setModifierLevel
(
int
level
)
{
this
.
modiferLevel
=
level
;
}
/**
* Retrieve armour Element.
*/
public
String
getElement
()
{
return
this
.
element
;
}
/**
* Set armour Element.
*/
public
void
setElement
(
String
e
)
{
this
.
element
=
e
;
}
/**
* Read Armour attributes.
*/
@
Override
public
void
read
(
Scanner
s
)
{
super
.
name
=
s
.
next
();
// Read in the remaining values
}
/**
* Clone--i.e., copy--this Armour.
*/
@
Override
public
Item
clone
()
{
return
null
;
}
/**
* *Print* one Armour.
*/
@
Override
public
String
toString
()
{
return
"This Is A Placeholder"
;
}
}
src/main/java/edu/odu/cs/cs330/items/Consumable.java
src/main/java/edu/odu/cs/cs330/items/Consumable.java
package
edu
.
odu
.
cs
.
cs330
.
items
;
import
java
.
util
.
Scanner
;
/**
* This class represents one Consumable Item--as found in most video games. This includes
* food.
*
* Consumable Items must be stackable. All Constructors must initialize Item::stackable
* to true.
*/
public
class
Consumable
extends
Item
{
protected
String
effect
;
///< effect recieved by using the Item
protected
int
uses
;
///< number of times this Item can be used
/**
* Default to a Comsumable Item with an empty name
*/
public
Consumable
()
{
// Make the necessary call to super(...)
this
.
effect
=
""
;
this
.
uses
=
0
;
}
/**
* Copy Constructor
*/
public
Consumable
(
Consumable
src
)
{
super
(
src
.
name
,
true
);
// Is this a hint???
this
.
effect
=
src
.
effect
;
this
.
uses
=
src
.
uses
;
}
/**
* Retrieve effect
*/
public
String
getEffect
()
{
return
this
.
effect
;
}
/**
* Set effect
*/
public
void
setEffect
(
String
effect
)
{
this
.
effect
=
effect
;
}
/**
* Retrieve number of uses
*/
public
int
getNumberOfUses
()
{
return
this
.
uses
;
}
/**
* Set number of uses
*/
public
void
setNumberOfUses
(
int
u
)
{
this
.
uses
=
u
;
}
/**
* Read Consumable Item attributes
*/
@
Override
public
void
read
(
Scanner
s
)
{
super
.
name
=
s
.
next
();
// Read in the remaining values
}
/**
* Clone--i.e., copy--this Consumable Item
*/
@
Override
public
Item
clone
()
{
return
null
;
}
/**
* *Print* the Consumable Item
*/
@
Override
public
String
toString
()
{
return
"This is a Placeholder"
;
}
}
src/main/java/edu/odu/cs/cs330/items/Inventory.java
src/main/java/edu/odu/cs/cs330/items/Inventory.java
package
edu
.
odu
.
cs
.
cs330
.
items
;
import
java
.
util
.
List
;
import
java
.
util
.
ArrayList
;
/**
* An Inventory is composed of n slots. Each slot may store only
* one type of item--specified by *slots*.
*
* Once all slots are filled, no additional Item types may be
* stored. Individual slots may contain any number of the same
* Item–if the Item is stackable.
*/
public
class
Inventory
{
private
List
<
ItemStack
>
slots
;
///< Individual item slots--each ItemStack represents one slot
private
int
capacity
;
///< Maximum inventory size
/**
* Default to 10 slots
*/
public
Inventory
()
{
this
.
slots
=
new
ArrayList
<
ItemStack
>
();
this
.
capacity
=
10
;
}
/**
* Create an inventory with n slots
*
*
@param
desiredCapacity size of the new Inventory
*/
public
Inventory
(
int
desiredCapacity
)
{
this
.
slots
=
new
ArrayList
<
ItemStack
>
();
this
.
capacity
=
desiredCapacity
;
}
/**
* Add one or more items to the inventory list
*
*
@return
true if *stack* was added and false otherwise
*/
public
boolean
addItems
(
ItemStack
stack
)
{
int
loc
=
slots
.
indexOf
(
stack
);
// if a match was found
if
(
loc
>=
0
)
{
// If the Item is stackable, add it to the ItemStack
if
(
slots
.
get
(
loc
).
permitsStacking
())
{
slots
.
get
(
loc
).
addItems
(
stack
.
size
());
return
true
;
}
}
if
(
slots
.
size
()
<
capacity
)
{
slots
.
add
(
stack
);
return
true
;
}
return
false
;
}
/**
* *Print* a Summary of the Inventory and all Items contained within.
*/
@
Override
public
String
toString
()
{
StringBuilder
strBld
=
new
StringBuilder
();
// Compute % full rounded to nearest whole number
int
percentFilled
=
(
int
)
Math
.
round
(
100.0
*
slots
.
size
()
/
capacity
);
// Print the usage summary
strBld
.
append
(
String
.
format
(
" -Used %3d%% of %d slots%n"
,
percentFilled
,
capacity
));
// Print the Items
for
(
ItemStack
slot
:
slots
)
{
strBld
.
append
(
slot
+
"\n"
);
}
return
strBld
.
toString
();
}
};
src/main/java/edu/odu/cs/cs330/items/Item.java
src/main/java/edu/odu/cs/cs330/items/Item.java
package
edu
.
odu
.
cs
.
cs330
.
items
;
import
java
.
util
.
Scanner
;
/**
* Item represents an individual Item in an inventory.
* This includes items such as potions, building materials, and food.
*
* Only one of each item can exist--i.e., no two items share the
* same numeric id.
*/
public
abstract
class
Item
implements
Cloneable
{
/**
* Indicates whether this Item can placed in an ItemStack larger than 1.
*/
private
boolean
stackable
;
/**
* Short title--e.g., HP Potion
*/
protected
String
name
;
/**
* Default to name = Air and stackable = true
*/
public
Item
()
{
this
.
name
=
"Air"
;
this
.
stackable
=
true
;
}
/**
* Create an Item with a specified and name
*
*
@param
name desired name
*
*
@pre
* - all items that share a name are of the same type
* - differences in capitalization denote different items
*/
public
Item
(
String
name
)
{
this
.
name
=
name
;
this
.
stackable
=
true
;
}
/**
* Create an Item with a specified id and name
*
*
@param
name desired name
*
@param
stackable flag that indicates whether duplicates
* of this item can be stacked
*
*
@pre
* - all items that share a name are of the same type
* - differences in capitalization denote different items
*/
public
Item
(
String
name
,
boolean
stackable
)
{
this
.
name
=
name
;
this
.
stackable
=
stackable
;
}
/**
* Retrieve name
*/
public
String
getName
()
{
return
this
.
name
;
}
/**
* Update name
*/
public
void
setName
(
String
n
)
{
this
.
name
=
n
;
}
/**
* Check for logical equivalence--based on name
*/
@
Override
public
boolean
equals
(
Object
rhs
)
{
Item
r
=
(
Item
)
rhs
;
return
this
.
name
.
equals
(
r
.
name
);
}
/**
* Generate a hash code based on name
*/
@
Override
public
int
hashCode
()
{
return
this
.
name
.
hashCode
();
}
/**
* Can this item be placed in a stack?
*/
public
boolean
isStackable
()
{
return
this
.
stackable
;
}
/**
* Read the item from an input array
*/
public
abstract
void
read
(
Scanner
s
);
/**
* Duplicate this item
*/
@
Override
public
abstract
Item
clone
();
/**
* *Print* an Item
*/
@
Override
public
String
toString
()
{
return
" "
+
this
.
name
;
}
}
src/main/java/edu/odu/cs/cs330/items/ItemFactory.java
src/main/java/edu/odu/cs/cs330/items/ItemFactory.java
package
edu
.
odu
.
cs
.
cs330
.
items
;
import
java
.
util
.
Scanner
;
/**
* The Item Creating Wizard
*/
public
class
ItemFactory
{
/**
* Name Item Pair 2-tuple(type, model)
*
* Simulate a c++ struct by making all attributes public
*/
private
static
class
ItemPair
{
public
String
type
;
///< Name of the item to clone
public
Item
model
;
///< Model of the item to clone
/**
* Default Constructor - Used as sentinel
*/
public
ItemPair
()
{
type
=
null
;
model
=
null
;
}
/**
* Non-Default Constructor
*
*
@param
type the type of anqq item
*
@param
item a cloneable item
*/
public
ItemPair
(
String
theType
,
Item
theItem
)
{
type
=
theType
;
model
=
theItem
;
}
}
/**
* Listing of known items
*/
private
static
ItemPair
[]
knownItems
=
{
new
ItemPair
(
"Armour"
,
new
Armour
()),
new
ItemPair
(
"Armor"
,
new
Armour
()),
//new ItemPair("Tool", new Tool()),
new
ItemPair
(
"Food"
,
new
Consumable
()),
new
ItemPair
(
"Potion"
,
new
Consumable
()),
new
ItemPair
(
"Disposable"
,
new
Consumable
()),
};
/**
* Create a Item
*
*
@param
type the item to be created
*
*
@return
A item with the specified type
* or nullptr if no matching item is found
*/
public
static
Item
createItem
(
String
type
)
{
for
(
ItemPair
pair
:
knownItems
)
{
if
(
pair
.
type
.
equals
(
type
))
{
return
pair
.
model
.
clone
();
}
}
return
null
;
}
/**
* Determine whether a given item is known
*
*
@param
type the item for which to query
*/
public
static
boolean
isKnown
(
String
type
)
{
for
(
ItemPair
pair
:
knownItems
)
{
if
(
pair
.
type
.
equals
(
type
))
{
return
true
;
}
}
return
false
;
}
/**
* Create the appropriate Item class--e.g., Tool, Armour or Consumable.
*
* How is **inheritance** used?
*/
public
static
Item
parseItemLine
(
Scanner
s
)
{
String
keyword
=
s
.
next
();
Item
item
=
createItem
(
keyword
);
// Parse the remainder of the line
if
(
item
!=
null
)
{
item
.
read
(
s
);
}
else
{
s
.
nextLine
();
}
return
item
;
}
}
src/main/java/edu/odu/cs/cs330/items/ItemStack.java
src/main/java/edu/odu/cs/cs330/items/ItemStack.java
package
edu
.
odu
.
cs
.
cs330
.
items
;
/**
* A Homogeneous--i.e., uniform--stack of Items.
*/
public
class
ItemStack
{
private
Item
item
;
///< Item out of which the stack is composed
private
int
quantity
;
///< Number of items in the stack
/**
* Default to an empty stack composed of Air
*/
public
ItemStack
()
{
this
.
item
=
null
;
this
.
quantity
=
0
;
}
/**
* Create a stack of type *item*
*
*
@param
item Item out of which the stack is composed
*/
public
ItemStack
(
Item
item
)
{
this
.
item
=
item
.
clone
();
this
.
quantity
=
1
;
}
/**
* Copy Constructor - Why is this necessary?
*/
public
ItemStack
(
ItemStack
src
)
{
this
.
item
=
src
.
item
.
clone
();
this
.
quantity
=
src
.
quantity
;
}
/**
* Retrieve the Item out of which the stack is composed
*/
public
Item
getItem
()
{
return
this
.
item
;
}
/**
* Retrieve the size of the stack
*/
public
int
size
()
{
return
this
.
quantity
;
}
/**
* Increase the size of the stack
*
*
@param
a number of items to add
*/
public
void
addItems
(
int
a
)
{
// Add *a* items if stacking is permitted
// otherwise, silently discard *a* items
if
(
item
.
isStackable
())
{
this
.
quantity
+=
a
;
}
}
/**
* Does that Item contained in this stack permit stacking?
*
* This can be less formally phrased, is this a stackable ItemStack?
*/
public
boolean
permitsStacking
()
{
return
item
.
isStackable
();
}
/**
* Consider two stacks to be the same if
* they contain the same type of Item
*/
@
Override
public
boolean
equals
(
Object
rhs
)
{
if
(
!
(
rhs
instanceof
ItemStack
))
{
return
false
;
}
ItemStack
r
=
(
ItemStack
)
rhs
;
return
this
.
item
.
equals
(
r
.
item
);
}
/**
* Generate a hash code based on item
*/
@
Override
public
int
hashCode
()
{
return
this
.
item
.
hashCode
();
}
/**
* Order stacks based on Item name
*/
//boolean operator<(ItemStack rhs);
/**
* Print the ItemStack directly
*/
@
Override
public
String
toString
()
{
String
outs
=
this
.
item
.
toString
();
if
(
this
.
permitsStacking
())
{
outs
+=
" Qty: "
+
this
.
quantity
+
"\n"
;
}
return
outs
;
}
}
src/main/java/edu/odu/cs/cs330/items/package-info.java
src/main/java/edu/odu/cs/cs330/items/package-info.java
/**
* All item and inventory classes and code are contained in this package.
*/
package
edu
.
odu
.
cs
.
cs330
.
items
;
src/main/java/edu/odu/cs/cs330/package-info.java
src/main/java/edu/odu/cs/cs330/package-info.java
/**
* The set of all CS 330 Code.
*/
package
edu
.
odu
.
cs
.
cs330
;
src/main/resources/items-01.txt
Tool Pickaxe Diamond 100 1 Fortune 5
LOLNOTAVALIDITEM potato 7
Tool Shovel Gold 20 3 Unbreaking 2
Tool Pickaxe Diamond 100 1 Fortune 5
Potion Speed-II-Potion Spd*2 1
Food Tomato Hunger-10 2
Disposable PotatoCamera ImageQuality-97% 5
Disposable PotatoCamera ImageQuality-97% 5
Tool Axe Stone 10 2 Unbreaking 2
Armour Boots Diamond 100 10 Protection 3 lightning
Armor Boots Diamond 100 10 FeatherFalling 4 lightning
src/main/resources/items-02.txt
Tool Pickaxe Diamond 100 1 Fortune 5
LOLNOTAVALIDITEM potato 7
Disposable PotatoCamera ImageQuality-97% 5
Tool Shovel Gold 20 3 Unbreaking 2
Tool Pickaxe Diamond 100 1 Fortune 5
Potion Speed-II-Potion Spd*2 1
Food Tomato Hunger-10 2
Disposable PotatoCamera ImageQuality-97% 5
Tool Axe Stone 10 2 Unbreaking 2
Armour Boots Diamond 100 10 Protection 3 lightning
Armor Boots Diamond 100 10 FeatherFalling 4 lightning
Armour ChestPlate Diamond 100 10 Defense 9 light
Potion Speed-II-Potion Spd*2 1
src/test/java/edu/odu/cs/cs330/items/TestArmour.java
src/test/java/edu/odu/cs/cs330/items/TestArmour.java
package
edu
.
odu
.
cs
.
cs330
.
items
;
import
org
.
junit
.
FixMethodOrder
;
import
org
.
junit
.
runners
.
MethodSorters
;
import
org
.
junit
.
Test
;
import
org
.
junit
.
Before
;
import
static
org
.
junit
.
Assert
.
*
;
import
static
org
.
hamcrest
.
CoreMatchers
.
*
;
import
org
.
hamcrest
.
core
.
IsNull
;
import
java
.
io
.
StringReader
;
import
java
.
util
.
Scanner
;
/**
* 1 - Does this piece of code perform the operations
* it was designed to perform?
*
* 2 - Does this piece of code do something it was not
* designed to perform?
*
* 1 Test per mutator
*/
@
FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
public
class
TestArmour
{
@
Test
public
void
testDefaultConstructor
()
{
Armour
genericArmour
=
new
Armour
();
Item
genericRef
=
(
Item
)
genericArmour
;
assertFalse
(
genericArmour
.
isStackable
());
assertFalse
(
genericRef
.
isStackable
());
// I should really complete this unit test with calls to each of the
// accessors. However, I will forgo the remaining checks for this test
// I should really check display() and/or operator<< here. However, I
// will do that in a separate `testDisplay` function
}
@
Test
public
void
testCopyConstructor
()
{
Armour
fancyArmour
=
new
Armour
();
fancyArmour
.
setName
(
"Fancy"
);
fancyArmour
.
setDurability
(
9001
);
fancyArmour
.
setDefense
(
62
);
fancyArmour
.
setMaterial
(
"Vibranium"
);
fancyArmour
.
setModifier
(
"ProcrastinationReduction"
);
fancyArmour
.
setModifierLevel
(
999999
);
fancyArmour
.
setElement
(
"H20"
);
Armour
copy
=
new
Armour
(
fancyArmour
);
// Checks
assertThat
(
copy
.
getName
(),
equalTo
(
"Fancy"
));
assertFalse
(
copy
.
isStackable
());
assertThat
(
copy
.
getDurability
(),
equalTo
(
9001
));
assertThat
(
copy
.
getDefense
(),
equalTo
(
62
));
assertThat
(
copy
.
getMaterial
(),
equalTo
(
"Vibranium"
));
assertThat
(
copy
.
getModifier
(),
equalTo
(
"ProcrastinationReduction"
));
assertThat
(
copy
.
getModifierLevel
(),
equalTo
(
999999
));
assertThat
(
copy
.
getElement
(),
equalTo
(
"H20"
));
// I should really check display() and/or operator<< here. However, I will
// do that in a separate `testDisplay` function
}
@
Test
public
void
testClone
()
{
Armour
fancyArmour
=
new
Armour
();
fancyArmour
.
setName
(
"Fancy"
);
fancyArmour
.
setDurability
(
9001
);
fancyArmour
.
setDefense
(
62
);
fancyArmour
.
setMaterial
(
"Vibranium"
);
fancyArmour
.
setModifier
(
"ProcrastinationReduction"
);
fancyArmour
.
setModifierLevel
(
999999
);
fancyArmour
.
setElement
(
"H20"
);
Armour
copy
=
(
Armour
)
fancyArmour
.
clone
();
// Checks
assertThat
(
copy
.
getName
(),
equalTo
(
"Fancy"
));
assertFalse
(
copy
.
isStackable
());
assertThat
(
copy
.
getDurability
(),
equalTo
(
9001
));
assertThat
(
copy
.
getDefense
(),
equalTo
(
62
));
assertThat
(
copy
.
getMaterial
(),
equalTo
(
"Vibranium"
));
assertThat
(
copy
.
getModifier
(),
equalTo
(
"ProcrastinationReduction"
));
assertThat
(
copy
.
getModifierLevel
(),
equalTo
(
999999
));
assertThat
(
copy
.
getElement
(),
equalTo
(
"H20"
));
// I should really check display() and/or operator<< here. However, I will
// do that in a separate `testDisplay` function
}
@
Test
public
void
testToString
()
{
Armour
fancyArmour
=
new
Armour
();
fancyArmour
.
setName
(
"Fancy"
);
fancyArmour
.
setDurability
(
9001
);
fancyArmour
.
setDefense
(
62
);
fancyArmour
.
setMaterial
(
"Vibranium"
);
fancyArmour
.
setModifier
(
"ProcrastinationReduction"
);
fancyArmour
.
setModifierLevel
(
999999
);
fancyArmour
.
setElement
(
"H20"
);
String
expected
=
" Nme: Fancy\n"
+
" Dur: 9001\n"
+
" Def: 62\n"
+
" Mtl: Vibranium\n"
+
" Mdr: ProcrastinationReduction (Lvl 999999)\n"
+
" Emt: H20\n"
;
assertThat
(
fancyArmour
.
toString
(),
equalTo
(
expected
));
}
@
Test
public
void
testRead
()
{
Armour
fancyArmour
=
new
Armour
();
String
inputStr
=
"Fancy Vibranium 9001 62 ProcrastinationReduction 999999 H20"
;
Scanner
ins
=
new
Scanner
(
new
StringReader
(
inputStr
));
fancyArmour
.
read
(
ins
);
// Checks
assertThat
(
fancyArmour
.
getName
(),
equalTo
(
"Fancy"
));
assertFalse
(
fancyArmour
.
isStackable
());
assertThat
(
fancyArmour
.
getDurability
(),
equalTo
(
9001
));
assertThat
(
fancyArmour
.
getDefense
(),
equalTo
(
62
));
assertThat
(
fancyArmour
.
getMaterial
(),
equalTo
(
"Vibranium"
));
assertThat
(
fancyArmour
.
getModifier
(),
equalTo
(
"ProcrastinationReduction"
));
assertThat
(
fancyArmour
.
getModifierLevel
(),
equalTo
(
999999
));
assertThat
(
fancyArmour
.
getElement
(),
equalTo
(
"H20"
));
}
}
src/test/java/edu/odu/cs/cs330/items/TestConsumable.java
src/test/java/edu/odu/cs/cs330/items/TestConsumable.java
package
edu
.
odu
.
cs
.
cs330
.
items
;
import
org
.
junit
.
FixMethodOrder
;
import
org
.
junit
.
runners
.
MethodSorters
;
import
org
.
junit
.
Test
;
import
org
.
junit
.
Before
;
import
static
org
.
junit
.
Assert
.
*
;
import
static
org
.
hamcrest
.
CoreMatchers
.
*
;
import
org
.
hamcrest
.
core
.
IsNull
;
import
java
.
io
.
StringReader
;
import
java
.
util
.
Scanner
;
/**
* 1 - Does this piece of code perform the operations
* it was designed to perform?
*
* 2 - Does this piece of code do something it was not
* designed to perform?
*
* 1 Test per mutator
*/
@
FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
public
class
TestConsumable
{
@
Test
public
void
testDefaultConstructor
()
{
Consumable
imagination
=
new
Consumable
();
Item
genericRef
=
(
Item
)
imagination
;
assertTrue
(
imagination
.
isStackable
());
assertTrue
(
genericRef
.
isStackable
());
// I should really complete this unit test with calls to each of the
// accessors. However, I will forgo the remaining checks for this test
// I should really check display() and/or operator<< here. However, I will
// do that in a separate `testDisplay` function
}
@
Test
public
void
testCopyConstructor
()
{
Consumable
tea
=
new
Consumable
();
tea
.
setName
(
"Green Tea"
);
tea
.
setEffect
(
"Wake Up"
);
tea
.
setNumberOfUses
(
10
);
Consumable
moreTea
=
new
Consumable
(
tea
);
assertThat
(
moreTea
.
isStackable
(),
is
(
true
));
assertThat
(
moreTea
.
getName
(),
equalTo
(
"Green Tea"
));
assertThat
(
moreTea
.
getEffect
(),
equalTo
(
"Wake Up"
));
assertThat
(
moreTea
.
getNumberOfUses
(),
is
(
10
));
// I should really complete this unit test with calls to each of the
// accessors. However, I will forgo the remaining checks for this test
// I should really check display() and/or operator<< here. However, I
// will do that in a separate `testDisplay` function
}
@
Test
public
void
testClone
()
{
Consumable
tea
=
new
Consumable
();
tea
.
setName
(
"Green Tea"
);
tea
.
setEffect
(
"Wake Up"
);
tea
.
setNumberOfUses
(
10
);
Consumable
moreTea
=
(
Consumable
)
tea
.
clone
();
assertThat
(
moreTea
.
isStackable
(),
is
(
true
));
assertThat
(
moreTea
.
getName
(),
equalTo
(
"Green Tea"
));
assertThat
(
moreTea
.
getEffect
(),
equalTo
(
"Wake Up"
));
assertThat
(
moreTea
.
getNumberOfUses
(),
is
(
10
));
// I should really complete this unit test with calls to each of the
// accessors. However, I will forgo the remaining checks for this test
// I should really check display() and/or operator<< here. However, I
// will do that in a separate `testDisplay` function
}
@
Test
public
void
testToString
()
{
Consumable
tea
=
new
Consumable
();
tea
.
setName
(
"Green Tea"
);
tea
.
setEffect
(
"Wake Up"
);
tea
.
setNumberOfUses
(
10
);
String
expected
=
" Nme: Green Tea\n"
+
" Eft: Wake Up\n"
+
" Use: 10\n"
;
assertThat
(
tea
.
toString
(),
equalTo
(
expected
));
}
@
Test
public
void
testRead
()
{
Consumable
tea
=
new
Consumable
();
String
inputStr
=
"Green-Tea Wake-Up 5"
;
Scanner
ins
=
new
Scanner
(
new
StringReader
(
inputStr
));
tea
.
read
(
ins
);
assertTrue
(
tea
.
isStackable
());
assertThat
(
tea
.
getName
(),
equalTo
(
"Green-Tea"
));
assertThat
(
tea
.
getEffect
(),
equalTo
(
"Wake-Up"
));
assertThat
(
tea
.
getNumberOfUses
(),
is
(
5
));
}
}
gradle/wrapper/gradle-wrapper.jar
META-INF/MANIFEST.MF
Manifest-Version: 1.0
Implementation-Title: Gradle
Implementation-Version: 3.1
org/gradle/wrapper/Download$1.class
package org.gradle.wrapper;
synchronized class Download$1 {
}
org/gradle/wrapper/Download$SystemPropertiesProxyAuthenticator.class
package org.gradle.wrapper;
synchronized class Download$SystemPropertiesProxyAuthenticator extends java.net.Authenticator {
private void Download$SystemPropertiesProxyAuthenticator();
protected java.net.PasswordAuthentication getPasswordAuthentication();
}
org/gradle/wrapper/IDownload.class
package org.gradle.wrapper;
public abstract interface IDownload {
public abstract void download(java.net.URI, java.io.File) throws Exception;
}
org/gradle/wrapper/GradleUserHomeLookup.class
package org.gradle.wrapper;
public synchronized class GradleUserHomeLookup {
public static final String DEFAULT_GRADLE_USER_HOME;
public static final String GRADLE_USER_HOME_PROPERTY_KEY = gradle.user.home;
public static final String GRADLE_USER_HOME_ENV_KEY = GRADLE_USER_HOME;
public void GradleUserHomeLookup();
public static java.io.File gradleUserHome();
static void
}
org/gradle/wrapper/ExclusiveFileAccessManager.class
package org.gradle.wrapper;
public synchronized class ExclusiveFileAccessManager {
public static final String LOCK_FILE_SUFFIX = .lck;
private final int timeoutMs;
private final int pollIntervalMs;
public void ExclusiveFileAccessManager(int, int);
public Object access(java.io.File, java.util.concurrent.Callable) throws Exception;
private static void maybeCloseQuietly(java.io.Closeable);
}
org/gradle/wrapper/WrapperConfiguration.class
package org.gradle.wrapper;
public synchronized class WrapperConfiguration {
private java.net.URI distribution;
private String distributionBase;
private String distributionPath;
private String distributionSha256Sum;
private String zipBase;
private String zipPath;
public void WrapperConfiguration();
public java.net.URI getDistribution();
public void setDistribution(java.net.URI);
public String getDistributionBase();
public void setDistributionBase(String);
public String getDistributionPath();
public void setDistributionPath(String);
public String getDistributionSha256Sum();
public void setDistributionSha256Sum(String);
public String getZipBase();
public void setZipBase(String);
public String getZipPath();
public void setZipPath(String);
}
org/gradle/wrapper/SystemPropertiesHandler.class
package org.gradle.wrapper;
public synchronized class SystemPropertiesHandler {
static final String SYSTEM_PROP_PREFIX = systemProp.;
public void SystemPropertiesHandler();
public static java.util.Map getSystemProperties(java.io.File);
}
org/gradle/wrapper/Logger.class
package org.gradle.wrapper;
public synchronized class Logger implements Appendable {
private final boolean quiet;
public void Logger(boolean);
public void log(String);
public Appendable append(CharSequence);
public Appendable append(CharSequence, int, int);
public Appendable append(char);
}
org/gradle/wrapper/PathAssembler.class
package org.gradle.wrapper;
public synchronized class PathAssembler {
public static final String GRADLE_USER_HOME_STRING = GRADLE_USER_HOME;
public static final String PROJECT_STRING = PROJECT;
private java.io.File gradleUserHome;
public void PathAssembler();
public void PathAssembler(java.io.File);
public PathAssembler$LocalDistribution getDistribution(WrapperConfiguration);
private String rootDirName(String, WrapperConfiguration);
private String getHash(String);
private String removeExtension(String);
private String getDistName(java.net.URI);
private java.io.File getBaseDir(String);
}
org/gradle/wrapper/Install.class
package org.gradle.wrapper;
public synchronized class Install {
public static final String DEFAULT_DISTRIBUTION_PATH = wrapper/dists;
private final Logger logger;
private final IDownload download;
private final PathAssembler pathAssembler;
private final ExclusiveFileAccessManager exclusiveFileAccessManager;
public void Install(Logger, IDownload, PathAssembler);
public java.io.File createDist(WrapperConfiguration) throws Exception;
private String calculateSha256Sum(java.io.File) throws Exception;
private java.io.File getAndVerifyDistributionRoot(java.io.File, String) throws Exception;
private void verifyDownloadChecksum(String, java.io.File, String) throws Exception;
private java.util.List listDirs(java.io.File);
private void setExecutablePermissions(java.io.File);
private boolean isWindows();
private boolean deleteDir(java.io.File);
private void unzip(java.io.File, java.io.File) throws java.io.IOException;
private void copyInputStream(java.io.InputStream, java.io.OutputStream) throws java.io.IOException;
}
org/gradle/wrapper/BootstrapMainStarter.class
package org.gradle.wrapper;
public synchronized class BootstrapMainStarter {
public void BootstrapMainStarter();
public void start(String[], java.io.File) throws Exception;
private java.io.File findLauncherJar(java.io.File);
}
org/gradle/wrapper/WrapperExecutor.class
package org.gradle.wrapper;
public synchronized class WrapperExecutor {
public static final String DISTRIBUTION_URL_PROPERTY = distributionUrl;
public static final String DISTRIBUTION_BASE_PROPERTY = distributionBase;
public static final String DISTRIBUTION_PATH_PROPERTY = distributionPath;
public static final String DISTRIBUTION_SHA_256_SUM = distributionSha256Sum;
public static final String ZIP_STORE_BASE_PROPERTY = zipStoreBase;
public static final String ZIP_STORE_PATH_PROPERTY = zipStorePath;
private final java.util.Properties properties;
private final java.io.File propertiesFile;
private final WrapperConfiguration config;
public static WrapperExecutor forProjectDirectory(java.io.File);
public static WrapperExecutor forWrapperPropertiesFile(java.io.File);
void WrapperExecutor(java.io.File, java.util.Properties);
private java.net.URI prepareDistributionUri() throws java.net.URISyntaxException;
private java.net.URI readDistroUrl() throws java.net.URISyntaxException;
private static void loadProperties(java.io.File, java.util.Properties) throws java.io.IOException;
public java.net.URI getDistribution();
public WrapperConfiguration getConfiguration();
public void execute(String[], Install, BootstrapMainStarter) throws Exception;
private String getProperty(String);
private String getProperty(String, String);
private String getProperty(String, String, boolean);
private String reportMissingProperty(String);
}
org/gradle/wrapper/GradleWrapperMain.class
package org.gradle.wrapper;
public synchronized class GradleWrapperMain {
public static final String GRADLE_USER_HOME_OPTION = g;
public static final String GRADLE_USER_HOME_DETAILED_OPTION = gradle-user-home;
public static final String GRADLE_QUIET_OPTION = q;
public static final String GRADLE_QUIET_DETAILED_OPTION = quiet;
public void GradleWrapperMain();
public static void main(String[]) throws Exception;
private static void addSystemProperties(java.io.File, java.io.File);
private static java.io.File rootDir(java.io.File);
private static java.io.File wrapperProperties(java.io.File);
private static java.io.File wrapperJar();
static String wrapperVersion();
private static java.io.File gradleUserHome(org.gradle.cli.ParsedCommandLine);
private static Logger logger(org.gradle.cli.ParsedCommandLine);
}
org/gradle/wrapper/Install$1.class
package org.gradle.wrapper;
synchronized class Install$1 implements java.util.concurrent.Callable {
void Install$1(Install, java.io.File, java.io.File, java.net.URI, WrapperConfiguration, String);
public java.io.File call() throws Exception;
}
org/gradle/wrapper/PathAssembler$LocalDistribution.class
package org.gradle.wrapper;
public synchronized class PathAssembler$LocalDistribution {
private final java.io.File distZip;
private final java.io.File distDir;
public void PathAssembler$LocalDistribution(PathAssembler, java.io.File, java.io.File);
public java.io.File getDistributionDir();
public java.io.File getZipFile();
}
org/gradle/wrapper/Download.class
package org.gradle.wrapper;
public synchronized class Download implements IDownload {
private static final int PROGRESS_CHUNK = 20000;
private static final int BUFFER_SIZE = 10000;
private final Logger logger;
private final String applicationName;
private final String applicationVersion;
public void Download(Logger, String, String);
private void configureProxyAuthentication();
public void download(java.net.URI, java.io.File) throws Exception;
private void downloadInternal(java.net.URI, java.io.File) throws Exception;
private String calculateUserAgent();
}
gradle-wrapper-classpath.properties
projects=gradle-cli
runtime=
build-receipt.properties
buildTimestamp=20160919105353+0000
commitId=13f38ba699afd86d7cdc4ed8fd7dd3960c0b1f97
isSnapshot=false
versionBase=3.1
versionNumber=3.1
org/gradle/cli/AbstractCommandLineConverter.class
package org.gradle.cli;
public abstract synchronized class AbstractCommandLineConverter implements CommandLineConverter {
public void AbstractCommandLineConverter();
public Object convert(Iterable, Object) throws CommandLineArgumentException;
}
org/gradle/cli/CommandLineParser$1.class
package org.gradle.cli;
synchronized class CommandLineParser$1 {
}
org/gradle/cli/CommandLineParser$MissingOptionArgState.class
package org.gradle.cli;
synchronized class CommandLineParser$MissingOptionArgState extends CommandLineParser$ParserState {
private final CommandLineParser$OptionParserState option;
private void CommandLineParser$MissingOptionArgState(CommandLineParser$OptionParserState);
public boolean maybeStartOption(String);
public CommandLineParser$OptionParserState onStartOption(String, String);
public CommandLineParser$ParserState onNonOption(String);
public void onCommandLineEnd();
}
org/gradle/cli/CommandLineParser$OptionStringComparator.class
package org.gradle.cli;
final synchronized class CommandLineParser$OptionStringComparator implements java.util.Comparator {
private void CommandLineParser$OptionStringComparator();
public int compare(String, String);
}
org/gradle/cli/CommandLineArgumentException.class
package org.gradle.cli;
public synchronized class CommandLineArgumentException extends RuntimeException {
public void CommandLineArgumentException(String);
public void CommandLineArgumentException(String, Throwable);
}
org/gradle/cli/CommandLineParser$KnownOptionParserState.class
package org.gradle.cli;
synchronized class CommandLineParser$KnownOptionParserState extends CommandLineParser$OptionParserState {
private final CommandLineParser$OptionString optionString;
private final CommandLineOption option;
private final ParsedCommandLine commandLine;
private final CommandLineParser$ParserState state;
private final java.util.List values;
private void CommandLineParser$KnownOptionParserState(CommandLineParser, CommandLineParser$OptionString, CommandLineOption, ParsedCommandLine, CommandLineParser$ParserState);
public CommandLineParser$ParserState onArgument(String);
public CommandLineParser$ParserState onStartNextArg();
public boolean getHasArgument();
public CommandLineParser$ParserState onComplete();
}
org/gradle/cli/CommandLineParser$OptionComparator.class
package org.gradle.cli;
final synchronized class CommandLineParser$OptionComparator implements java.util.Comparator {
private void CommandLineParser$OptionComparator();
public int compare(CommandLineOption, CommandLineOption);
}
org/gradle/cli/CommandLineParser$UnknownOptionParserState.class
package org.gradle.cli;
synchronized class CommandLineParser$UnknownOptionParserState extends CommandLineParser$OptionParserState {
private final CommandLineParser$ParserState state;
private final String arg;
private final ParsedCommandLine commandLine;
private void CommandLineParser$UnknownOptionParserState(String, ParsedCommandLine, CommandLineParser$ParserState);
public boolean getHasArgument();
public CommandLineParser$ParserState onStartNextArg();
public CommandLineParser$ParserState onArgument(String);
public CommandLineParser$ParserState onComplete();
}
org/gradle/cli/CommandLineOption.class
package org.gradle.cli;
public synchronized class CommandLineOption {
private final java.util.Set options;
private Class argumentType;
private String description;
private String deprecationWarning;
private boolean incubating;
private final java.util.Set groupWith;
public void CommandLineOption(Iterable);
public java.util.Set getOptions();
public CommandLineOption hasArgument(Class);
public CommandLineOption hasArgument();
public CommandLineOption hasArguments();
public String getDescription();
public CommandLineOption hasDescription(String);
public boolean getAllowsArguments();
public boolean getAllowsMultipleArguments();
public CommandLineOption deprecated(String);
public CommandLineOption incubating();
public String getDeprecationWarning();
java.util.Set getGroupWith();
void groupWith(java.util.Set);
}
org/gradle/cli/CommandLineParser$OptionParserState.class
package org.gradle.cli;
abstract synchronized class CommandLineParser$OptionParserState {
private void CommandLineParser$OptionParserState();
public abstract CommandLineParser$ParserState onStartNextArg();
public abstract CommandLineParser$ParserState onArgument(String);
public abstract boolean getHasArgument();
public abstract CommandLineParser$ParserState onComplete();
}
org/gradle/cli/ParsedCommandLine.class
package org.gradle.cli;
public synchronized class ParsedCommandLine {
private final java.util.Map optionsByString;
private final java.util.Set presentOptions;
private final java.util.Set removedOptions;
private final java.util.List extraArguments;
void ParsedCommandLine(Iterable);
public String toString();
private String quoteAndJoin(Iterable);
public boolean hasOption(String);
public boolean hadOptionRemoved(String);
public boolean hasAnyOption(java.util.Collection);
public ParsedCommandLineOption option(String);
public java.util.List getExtraArguments();
void addExtraValue(String);
ParsedCommandLineOption addOption(String, CommandLineOption);
void removeOption(CommandLineOption);
}
org/gradle/cli/ProjectPropertiesCommandLineConverter.class
package org.gradle.cli;
public synchronized class ProjectPropertiesCommandLineConverter extends AbstractPropertiesCommandLineConverter {
public void ProjectPropertiesCommandLineConverter();
protected String getPropertyOption();
protected String getPropertyOptionDetailed();
protected String getPropertyOptionDescription();
}
org/gradle/cli/CommandLineParser$CaseInsensitiveStringComparator.class
package org.gradle.cli;
final synchronized class CommandLineParser$CaseInsensitiveStringComparator implements java.util.Comparator {
private void CommandLineParser$CaseInsensitiveStringComparator();
public int compare(String, String);
}
org/gradle/cli/CommandLineParser.class
package org.gradle.cli;
public synchronized class CommandLineParser {
private static final java.util.regex.Pattern OPTION_NAME_PATTERN;
private java.util.Map optionsByString;
private boolean allowMixedOptions;
private boolean allowUnknownOptions;
private final java.io.PrintWriter deprecationPrinter;
public void CommandLineParser();
public void CommandLineParser(java.io.Writer);
public transient ParsedCommandLine parse(String[]) throws CommandLineArgumentException;
public ParsedCommandLine parse(Iterable) throws CommandLineArgumentException;
public CommandLineParser allowMixedSubcommandsAndOptions();
public CommandLineParser allowUnknownOptions();
public transient CommandLineParser allowOneOf(String[]);
public void printUsage(Appendable);
private static String join(java.util.Collection, String);
public transient CommandLineOption option(String[]);
static void
}
org/gradle/cli/CommandLineParser$AfterOptions.class
package org.gradle.cli;
synchronized class CommandLineParser$AfterOptions extends CommandLineParser$ParserState {
private final ParsedCommandLine commandLine;
private void CommandLineParser$AfterOptions(ParsedCommandLine);
public boolean maybeStartOption(String);
public CommandLineParser$OptionParserState onStartOption(String, String);
public CommandLineParser$ParserState onNonOption(String);
}
org/gradle/cli/CommandLineParser$OptionString.class
package org.gradle.cli;
synchronized class CommandLineParser$OptionString {
private final String arg;
private final String option;
private void CommandLineParser$OptionString(String, String);
public String getDisplayName();
public String toString();
}
org/gradle/cli/AbstractPropertiesCommandLineConverter.class
package org.gradle.cli;
public abstract synchronized class AbstractPropertiesCommandLineConverter extends AbstractCommandLineConverter {
public void AbstractPropertiesCommandLineConverter();
protected abstract String getPropertyOption();
protected abstract String getPropertyOptionDetailed();
protected abstract String getPropertyOptionDescription();
public void configure(CommandLineParser);
public java.util.Map convert(ParsedCommandLine, java.util.Map) throws CommandLineArgumentException;
}
org/gradle/cli/ParsedCommandLineOption.class
package org.gradle.cli;
public synchronized class ParsedCommandLineOption {
private final java.util.List values;
public void ParsedCommandLineOption();
public String getValue();
public java.util.List getValues();
public void addArgument(String);
public boolean hasValue();
}
org/gradle/cli/CommandLineParser$OptionAwareParserState.class
package org.gradle.cli;
abstract synchronized class CommandLineParser$OptionAwareParserState extends CommandLineParser$ParserState {
protected final ParsedCommandLine commandLine;
protected void CommandLineParser$OptionAwareParserState(CommandLineParser, ParsedCommandLine);
public boolean maybeStartOption(String);
public CommandLineParser$ParserState onNonOption(String);
}
org/gradle/cli/CommandLineConverter.class
package org.gradle.cli;
public abstract interface CommandLineConverter {
public abstract Object convert(Iterable, Object) throws CommandLineArgumentException;
public abstract Object convert(ParsedCommandLine, Object) throws CommandLineArgumentException;
public abstract void configure(CommandLineParser);
}
org/gradle/cli/CommandLineParser$BeforeFirstSubCommand.class
package org.gradle.cli;
synchronized class CommandLineParser$BeforeFirstSubCommand extends CommandLineParser$OptionAwareParserState {
private void CommandLineParser$BeforeFirstSubCommand(CommandLineParser, ParsedCommandLine);
public CommandLineParser$OptionParserState onStartOption(String, String);
}
org/gradle/cli/SystemPropertiesCommandLineConverter.class
package org.gradle.cli;
public synchronized class SystemPropertiesCommandLineConverter extends AbstractPropertiesCommandLineConverter {
public void SystemPropertiesCommandLineConverter();
protected String getPropertyOption();
protected String getPropertyOptionDetailed();
protected String getPropertyOptionDescription();
}
org/gradle/cli/CommandLineParser$ParserState.class
package org.gradle.cli;
abstract synchronized class CommandLineParser$ParserState {
private void CommandLineParser$ParserState();
public abstract boolean maybeStartOption(String);
boolean isOption(String);
public abstract CommandLineParser$OptionParserState onStartOption(String, String);
public abstract CommandLineParser$ParserState onNonOption(String);
public void onCommandLineEnd();
}
org/gradle/cli/CommandLineParser$AfterFirstSubCommand.class
package org.gradle.cli;
synchronized class CommandLineParser$AfterFirstSubCommand extends CommandLineParser$OptionAwareParserState {
private void CommandLineParser$AfterFirstSubCommand(CommandLineParser, ParsedCommandLine);
public CommandLineParser$OptionParserState onStartOption(String, String);
}
gradle-cli-classpath.properties
projects=
runtime=
gradle/wrapper/gradle-wrapper.properties
#Wed Feb 22 15:34:37 EST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-all.zip
config/checkstyle/checkstyle.xml
build.gradle
buildscript {
repositories {
jcenter()
}
}
plugins {
id “java”
id “application”
id “eclipse”
id “checkstyle”
id “com.github.spotbugs” version “2.0.0”
id “project-report”
id “jacoco”
id “pmd”
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
jcenter()
}
dependencies {
testCompile “junit:junit:4.12”
testCompile “org.hamcrest:hamcrest-library:1.3”
}
jar {
baseName = “Storage”
manifest {
attributes(
“Main-Class”: “edu.odu.cs.cs330.Storage”
)
}
}
application {
mainClassName = “edu.odu.cs.cs330.Storage”
}
run {
main = “edu.odu.cs.cs330.Storage”
args = [“src/main/resources/items-01.txt”]
}
test {
reports {
html.enabled = true
}
ignoreFailures = true
testLogging {
events “passed”, “skipped”, “failed”, “standardOut”, “standardError”
}
}
javadoc {
failOnError false
}
//——————————————————————————
// Analysis Tools
//——————————————————————————
// SpotBugs
spotbugsMain {
ignoreFailures = true
effort = “max”
reportLevel = “medium”
reports {
xml.enabled = false
html.enabled = true
}
}
spotbugsTest.enabled = false
// End SpotBugs config
jacoco {
toolVersion = “0.8.5”
}
jacocoTestReport {
reports {
html.enabled true
xml.enabled true
csv.enabled true
}
}
// Check Style Config
checkstyle {
ignoreFailures = true
showViolations = false
configFile = “checkstyle.xml” as File
}
tasks.withType(Checkstyle) {
reports {
html.destination project.file(“build/reports/checkstyle/main.html”)
}
}
checkstyleTest.enabled = false
// End Checkstyle config
pmd {
ignoreFailures = true
ruleSets = [
“category/java/bestpractices.xml”,
“category/java/codestyle.xml”,
“category/java/design.xml”,
“category/java/errorprone.xml”,
“category/java/performance.xml”
]
}
gradle.properties
org.gradle.daemon=false