CSE 241/505 Homework # 7 Inheritance in Java solved

$35.00

Description

In this homework, you will implement a class hierarchy in Java very similar to HW5. You will design
and implement a Java class hierarchy for the Board class of the NPuzzle problem. You will also write
static methods to use these classes.
Your AbstractBoard class represents the board configuration as you did in the previous
homework assignments.
method Name Explanation
toString produces the board as string
readFromFile Reads the board from the file given as function parameter. The file
format is defined as in HW2.
writeToFile Writes the board to the file given as function parameter
reset Resets the board to the solution.
setSize Sets the board size to given values. The values are given as parameters
and there are no restrictions on the board size. The board is reset after
this operation.
move Makes a move according to the given char parameter. If the parameter
is ‘L’ then the blank tiles moves left, …, etc, as defined in HW1.
isSolved Returns true if the board is a solution
cell Takes two indexes and returns the corresponding cell content.
Terminates program if the indexes are not valid.
Equals Two boards are equal, if the boards are the same. This operator does
not consider last move or the number of steps
NumberOfBoards Returns the number of Board objects created so far.
lastMove Returns the last move, if there is no last move, returns ‘S’
numberOfMoves Returns the number of steps (moves) this board made
Many of the methods above cannot be implemented because your do not know how the board is
represented in this abstract base class. You will extend 3 new concrete classes from this class that
represents the boards in different ways:
 BoardArray1D: The Board is represented using a one dimensional Java array.
 BoardArray2D: The Board is represented using a two dimensional Java array.
Write a static method that takes an array of AbstractBoard references and returns true if the
array contains a valid sequence of moves for a solution (same question of the midterm exam).
Notes:
 Use appropriate comments for JavaDoc and submit your documentation files.
 Test each method of each class at least once by writing driver code.
 Test the static method at least 5 times with different number of types of boards.
 You should submit your work to the moodle page and follow all the submission rules that will
be posted.