Java assignment 6 with class diagram and Junit test.
Broncos/build.xml
Builds, tests, and runs the project Broncos.Broncos/manifest.mf
Manifest-Version: 1.0 X-COMMENT: Main-Class will be added automatically by build
Broncos/nbproject/build-impl.xml
Must set src.dir Must set test.src.dir Must set build.dir Must set dist.dir Must set build.classes.dir Must set dist.javadoc.dir Must set build.test.classes.dir Must set build.test.results.dir Must set build.classes.excludes Must set dist.jar Must set javac.includes No tests executed. Must set JVM to use for profiling in profiler.info.jvm Must set profiler agent JVM arguments in profiler.info.jvmargs.agentBroncos/nbproject/genfiles.properties
build.xml.data.CRC32=dd03dd72 build.xml.script.CRC32=ab548cbe [email protected] # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=dd03dd72 nbproject/build-impl.xml.script.CRC32=24a063c6 nbproject/[email protected]
Broncos/nbproject/project.properties
annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processor.options= annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output build.classes.dir=${build.dir}/classes build.classes.excludes=**/*.java,**/*.form # This directory is removed when the project is cleaned: build.dir=build build.generated.dir=${build.dir}/generated build.generated.sources.dir=${build.dir}/generated-sources # Only compile against the classpath explicitly listed here: build.sysclasspath=ignore build.test.classes.dir=${build.dir}/test/classes build.test.results.dir=${build.dir}/test/results # Uncomment to specify the preferred debugger connection transport: #debug.transport=dt_socket debug.classpath=\ ${run.classpath} debug.modulepath=\ ${run.modulepath} debug.test.classpath=\ ${run.test.classpath} debug.test.modulepath=\ ${run.test.modulepath} # Files in build.classes.dir which should be excluded from distribution jar dist.archive.excludes= # This directory is removed when the project is cleaned: dist.dir=dist dist.jar=${dist.dir}/Broncos.jar dist.javadoc.dir=${dist.dir}/javadoc excludes= includes=** jar.compress=false javac.classpath= # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false javac.external.vm=true javac.modulepath= javac.processormodulepath= javac.processorpath=\ ${javac.classpath} javac.source=1.8 javac.target=1.8 javac.test.classpath=\ ${javac.classpath}:\ ${build.classes.dir}:\ ${libs.junit_4.classpath}:\ ${libs.hamcrest.classpath} javac.test.modulepath=\ ${javac.modulepath} javac.test.processorpath=\ ${javac.test.classpath} javadoc.additionalparam= javadoc.author=false javadoc.encoding=${source.encoding} javadoc.noindex=false javadoc.nonavbar=false javadoc.notree=false javadoc.private=false javadoc.splitindex=true javadoc.use=true javadoc.version=false javadoc.windowtitle= main.class=broncos.MonthCollection manifest.file=manifest.mf meta.inf.dir=${src.dir}/META-INF mkdist.disabled=false platform.active=default_platform run.classpath=\ ${javac.classpath}:\ ${build.classes.dir} # Space-separated list of JVM arguments used when running the project. # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. # To set system properties for unit tests define test-sys-prop.name=value: run.jvmargs= run.modulepath=\ ${javac.modulepath} run.test.classpath=\ ${javac.test.classpath}:\ ${build.test.classes.dir} run.test.modulepath=\ ${javac.test.modulepath} source.encoding=UTF-8 src.dir=src test.src.dir=test
Broncos/nbproject/project.xml
org.netbeans.modules.java.j2seproject BroncosBroncos/src/broncos/Month.java
Broncos/src/broncos/Month.java
package
broncos
;
public
class
Month
<
T
>
{
private
T month
;
public
void
add
(
T month
)
{
this
.
month
=
month
;
}
public
T get
()
{
return
month
;
}
}
Broncos/src/broncos/MonthCollection.java
Broncos/src/broncos/MonthCollection.java
package
broncos
;
import
java
.
util
.
ArrayList
;
public
class
MonthCollection
{
public
static
void
main
(
String
[]
args
)
{
// add 12 months in integer format and 12 months in string format
ArrayList
<
Month
>
intMonths
=
new
ArrayList
<>
();
ArrayList
<
Month
>
stringMonths
=
new
ArrayList
<>
();
String
[]
calendarMonths
=
new
String
[]{
"January"
,
"February"
,
"March"
,
"April"
,
"May"
,
"June"
,
"July"
,
"August"
,
"September"
,
"October"
,
"November"
,
"December"
};
Month
intMonth
,
stringMonth
;
for
(
int
i
=
1
;
i
<=
12
;
i
++
)
{
//add integer months to collection
intMonth
=
new
Month
();
intMonth
.
add
(
i
);
intMonths
.
add
(
intMonth
);
//add string months to collection
stringMonth
=
new
Month
();
stringMonth
.
add
(
calendarMonths
[
i
-
1
]);
stringMonths
.
add
(
stringMonth
);
}
//print out string months
printMonths
(
stringMonths
);
//print our all integer months
printMonths
(
intMonths
);
}
private
static
void
printMonths
(
ArrayList
<
Month
>
months
)
{
for
(
Month
month
:
months
){
System
.
out
.
println
(
"Month = "
+
month
.
get
()
+
" type= "
+
month
.
get
().
getClass
());
}
System
.
out
.
println
();
}
}
Broncos/test/broncos/MonthTest.java
Broncos/test/broncos/MonthTest.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
broncos
;
import
org
.
junit
.
Test
;
import
static
org
.
junit
.
Assert
.
*
;
/**
*
*
@author
fumba
*/
public
class
MonthTest
{
/**
* Test of add method, make sure that Integer months are saved as Integers
*/
@
Test
public
void
testAddInteger
()
{
Month
instance
=
new
Month
();
instance
.
add
(
1
);
assertEquals
(
Integer
.
class
,
instance
.
get
().
getClass
());
}
/**
* Test of add method, make sure that String months are saved as Strings
*/
@
Test
public
void
testAddString
()
{
Month
instance
=
new
Month
();
instance
.
add
(
"January"
);
assertEquals
(
String
.
class
,
instance
.
get
().
getClass
());
}
/**
* Test of get method, of class Month.
*/
@
Test
public
void
testGetString
()
{
Month
instance
=
new
Month
();
instance
.
add
(
"january"
);
assertEquals
(
instance
.
get
(),
"january"
);
}
/**
* Test of get method, of class Month.
*/
@
Test
public
void
testGetInteger
()
{
Month
instance
=
new
Month
();
instance
.
add
(
1
);
assertEquals
(
instance
.
get
(),
1
);
}
}