In this exercise you will install and use the problem solving
framework discussed in class (see menu to the left).
To begin, download this zipped project folder to an appropriate location on
your machine and import
it into NetBeans:
ProblemSolver.zip.
This will produce a project called
ProblemSolver whose
structure looks like that below.
Note the
domains.dummy and
domains.arithmetic
packages under both
Source Packages and
Test
Packages.
Open the
ProblemSolver project in NetBeans and open the source
folders.
The project structure should look like this:
Name the project
ProblemSolver and choose for location the
ProblemSolver folder you just unzipped (extracted).
Click
Next.
In the next screen,
click the
Add Folder... button next to the
Source Package
Folders: area.
In the
Browse Source Packages Folder dialog,
navigate to the
src folder inside the
ProblemSolver
folder. Click
Open.
After locating the sources, the
Existing Sources screen should
look similar to that below.
Now click the
Add Folder... button in the
Test Package
Folders section.
Clicking the
Add Folder... button in the
Test Package
Folders section brings up a file browser dialog. Click the new
folder icon circled in red below.
Name the folder "
test", be sure to type
ENTER, and click
OK.
When finished, the source and test package folders should be similar to
those below. Click
Finish.
Open the handles on the
ProblemSolver project in the
Projects
tab and open the associated subfolders. The structure must look like
this:
Right click the
DummyProblemTest.java node under
Test Packages
and choose
Test
File, as shown below left.
You should get the dummy application described in the problem solving
framework lecture, also shown below.
Familiarize yourself with the use of the application.
Your job for this exercise is to become familiar with the problem
solving framework by creating a simple arithmetic problem application.
A screenshot of the problem is shown below.
To see how it is used, refer to the
Video (mp4) for this module.
The classes you will implement fit into the problem solving framework in
exactly the same way the classes for the dummy application (described
in the problem solving framework lecture). See below.
You should model your arithmetic problem classes on their dummy problem
counterparts.
Create a new source package called
domains.arithmetic and
add the new class files:
- ArithmeticState.java
- ArithmeticMover.java
- ArithmeticProblem.java
Create a test class for
ArithmeticProblem.java.
Your project structure must look like:
This section describes how to implement and test the classes.
Since
ArithmeticState does not depend on any other domain
classes, start with it first.
Like
DummyState, your
ArithmeticState class must extend
the framework's abstract
State class. A template for the
class is given for you and shown below.
- Decide on a state representation, that is, how you are going
to store the value of an ArithmeticState
object. This value is given to
the ArithmeticState constructor.
- Override the equals method so that it
returns true if the state is the same as another state.
- Override the toString method so that it returns
a display of the state: "The value is: N"
where N is the state's value.
Use the
DummyState example as a model. Do not move on until you
have successfully tested it.
When you have written the
ArithmeticState class, test it
with the provided
ArithmeticStateTest.java file, displayed to the right.
Right click
ArithmeticStateTest.java in the project tree
and select
Test File.
When it is working correctly, the results will look like:
Like
DummyMover, your
ArithmeticMover class must extend
the framework's abstract
Mover class. A template for the
class is given for you and shown below.
- The constructor must make calls to the parent's addMove
method to add move names and their associated functional
objects
- Any methods that take a State argument will have to cast
it to ArithmeticState first
Use the
DummyMover example as a model. Do not move on until you
have successfully tested it.
When you have written the
ArithmeticMover class, test it
with the provided
ArithmeticMoverTest.java file, displayed to the right.
Right click
ArithmeticMoverTest.java in the project tree
and select
Test File.
When it is working correctly, the results will look like:
Like
DummyProblem, your
ArithmeticProblem class must extend
the framework's
Problem class. A template for the
class is given for you and shown below.
- The constructor must make appropriate calls to the parent's
setter methods
Use the
DummyProblem example as a model. Do not move on until you
have successfully tested it.
When you have written the
ArithmeticProblem class, test
it with the provided
ArithmeticProblemTest.java file, displayed to the right.
Right click
ArithmeticProblemTest.java in the project tree
and select
Test File.
A console will appear and you can manually try moves and solve
the problem. When you exit the console the results of the
automated tests will be displayed.
If it is working correctly, the results will look like:
Like
DummyConsole, your
ArithmeticConsole class must use
the framework's
ProblemConsole class:
- ArithmeticConsole will be just like DummyConsole
except for its name and the type of object given to
the ProblemConsole constructor
- It is not necessary at this point to understand the details of
how JavaFX is used to produce the console window
There is no separate test class for
ArithmeticConsole. To test
it, simply run it and interact with the application. If your previous
tests have succeeded, it will run like the
ArithmeticSolver.jar
application.
The test files required for this exercise are available from the menu on the
left.
When your arithmetic problem is working correctly:
- Make sure your identifying information is in the class comments
of all arithmetic files
- Use the NetBeans Export Project feature to
create ProblemSolver.zip in a location other than
your project folder.
- Submit ProblemSolver.zip by going to
Note the general
Submission Policy in the menu at left.
Your project will be inspected, tested, and run by the lab instructor. Grading criteria:
- (9 points) Successful running of the three test classes
ArithmeticStateTest, ArithmeticMoverTest,
and ArithmeticProblemTest
- (1 point) Adequate javadoc documentation