CS 102, Project 5
CS 102, Project 5
USER INTERFACE
https://cs.nyu.edu/~joannakl/cs102/projects/project5_binary_maze.html Page 1 of 9
CS 102, Project 5 12/2/24, 12:46 PM
PROGRAM USAGE
The program is started from the command line (or run within an IDE).
It expects one command line argument: the name of the input file.
The input file describes the binary tree maze. Each line in the input is
a single node in the maze (node in a BST). The format of each line is
as follows:
` LABEL LIFE_POINTS`
In the above, LABEL is a string with the name of the node. The
alphanumeric comparison of the labels determines the shape of the
tree. LIFE_POINTS is a number of life points that our hero can collect
at that node.
See below for an example.
If the program is executed with non-existent or invalid command line
argument, it should print an error message and terminate.
If the file contains any additional (and invalid) strings in the
description of a node, those extra strings should be ignored. (Each
valid line contains only one string followed by one number.)
The program should not be interactive. All input should be provided
as the command line arguments. The user should not be prompted for
any additional information.
RESULTS/OUTPUT
The program has to calculate all possible paths through the maze that
lead to the valid exits that are reachable by our hero. Valid exits are
leaves in the tree that are at the lowest level. But our hero needs to
have enough life points to reach such an exit. If the life points run out
before the exit can be reached, the path to such an exit should not be
listed among the ones recommended by your program.
The program output should consist of a number of lines equal to the
number of valid paths. Each valid path should consist of a space
separated list of the node labels in order in which they are followed
from the root of the tree to the leaves that are valid exits. The paths
https://cs.nyu.edu/~joannakl/cs102/projects/project5_binary_maze.html Page 2 of 9
CS 102, Project 5 12/2/24, 12:46 PM
should be printed in order from left to right in the binary search tree
that represents the maze (this is also the alphanumeric ordering of the
paths).
EXAMPLE
J2
G.1 0.0
B I 1 L3 R1
AO C1 H1: K2 О.
E2 N.2 P.1 51 V1
DO FO T.1
The above figure depicts visually a tree that results from the following
input file
J 2
G 1
Q 0
B 0
I 1
A 0
C 1
E 2
D 0
H 1
F 0
L 3
R 1
U 0
S 1
V 1
T 1
https://cs.nyu.edu/~joannakl/cs102/projects/project5_binary_maze.html Page 3 of 9
CS 102, Project 5 12/2/24, 12:46 PM
K 2
O 0
P 1
N 2
M 0
The starting point for the maze is at its root at node lebeled "J". The
valid exits from the maze are at the nodes at the lowest level. They
are labeled "D", "F", "M", and "T". There are trap doors at any leaf
node that is not at the lowest level. They are nodes labeled "A", "H",
"K", "P", and "V".
The tree also shows the number of life points that the hero can collect
at each of the life-points. Note that if a number of life points at the
room is less than one, the hero cannot go anywhere since they need
exactly one life-point to travel from one node to the next.
There are several possible paths through the maze depicted above, but
only three lead to reachable valid exits that are reachable by our hero
with sufficient life points. The four paths that reach the bottom-most
level are J G B C E D, J G B C E F, J Q L O N M, and J Q R
U S T. The last path does not allow our hero to collect enough life
points to make it to the bottom-most level.
In this case, the program should produce three lines of output:
J G B C E D
J G B C E F
J Q L O N M
BinaryTreeMaze class
This is the class that is the program. This means it has the main
method. This class is responsible for parsing and validating the
command line arguments, reading and parsing the input file,
producing any error messages, handling any exceptions thrown by
other classes, and producing output.
BST<E> class
https://cs.nyu.edu/~joannakl/cs102/projects/project5_binary_maze.html Page 4 of 9
CS 102, Project 5 12/2/24, 12:46 PM
https://cs.nyu.edu/~joannakl/cs102/projects/project5_binary_maze.html Page 5 of 9
CS 102, Project 5 12/2/24, 12:46 PM
UnsopportedOperationException.)
RESTRICTION: You should not use an iterator that is already
implemented in one of the Java classes (like the one in the
ArrayList class). In practice, this would be a good idea, but the
objective here is for you to implement yout own iterator.
Maze class
This should be the class that inherits from your own
BST<MazeNode>. Your class should represent the maze itself
(therefore, it should not be generic and its nodes should store data
items of type MazeNode). It is up to you to decide how to implement
this class, which methods to provide etc. The important distinction is
that the Maze class should contain all the methods that are specific to
the maze itself, not the general BST methods that are inherited from
the BST class.
MazeNode class
This class should represent the points in the maze at which our hero
can collect life-points and at which they need to make a decisions as
to which way to continue. It should be capable of storing the label of
the node and the number of possible life points our hero can collect at
this maze node. It may be useful (or may be even necessary) to
implement the Comparable interface.
Note that his is NOT the same as the internal Node class for the BST
class itself.
Hero class
This class should represent our hero traveling through the maze. An
object of this class should be capable of keeping track of all the life
points that our hero possesses at any given time. This information
should be updated as the hero travels along the different potential
paths through the maze.
You may, but you are not required to, implement other classes.
PROGRAMMING RULES
https://cs.nyu.edu/~joannakl/cs102/projects/project5_binary_maze.html Page 6 of 9
CS 102, Project 5 12/2/24, 12:46 PM
The BST class that you implement should be just a basic binary
search tree. Do not try to implement a balanced tree (doing this
will change the shape of the maze and will result in incorrect
paths).
You may use any exception-related classes.
before the due dates - make sure that you have working code if
that happens.
GRADING
https://cs.nyu.edu/~joannakl/cs102/projects/project5_binary_maze.html Page 8 of 9
CS 102, Project 5 12/2/24, 12:46 PM
should look at all the files that Gradescope has - make sure there is
nothing there that should not be there.
You may resubmit to Gradescope as many times as you wish before
the submission link closes. But if you resubmit after the grace period
ends, your assignment will be subject to the late point deductions.
For this project, you will see some of the results for the autograded
unit tests. Some of the results will be hidden. (When some results are
hidden, Gradescope does not display the score for the autograded
part. )
https://cs.nyu.edu/~joannakl/cs102/projects/project5_binary_maze.html Page 9 of 9