Sale!

EECS268 : Lab5

$30.00

Category:

Description

Rate this product

EECS268: Lab5

This lab is due one week from the start of your lab.
Overview
Flood!
There is a flood happening and you have to figure out what areas will be affected. You’ll be provided a map indicating where the flooding is coming from and where the high grounds and low grounds are in order to figure which area will be flooded.
File Format
<numRows> <numCols>
<startRow> <startCol>
<water amount>
<map characters>
•    Num rows and columns indicate the maps dimensions
•    Start row and column are where flooding begins
•    Water amount is how many spaces this flood could fill
•    The row and columns coordinates range from 0 to (numRows-1) and 0 to (numCols-1)
•    The top left of the map would be considered 0,0
The map consists of:
•    Spaces (‘ ‘) = low ground, the areas that water can move into
•    H = High ground, water cannot flood or cross over
A file is invalid and the program should end with an error message if…
•    if file doesn’t exist
•    if numRows are less than 1
•    if numCols are less than 1
•    if start position is not within range
You may assume the map characters match the parameters given above.
Flooding Rules
•    Flooding starts at the start position
•    Water only moves orthogonally (up, right, down, or left) not diagonally
•    You must check for valid moves in the order: up, right, down, left
•    You cannot move through the high ground
•    If you run out of water the flooding stops
•    If no more spaces can be flooded, the flooding stops
•    Remember, the water cannot cross the high ground!
Output
After receiving a file from command you will output the path of the flood to the screen. Every space that was flooded will have a ‘~’ to indicate it was flooded.
Also, indicate if the flood ran out of water or if it flooded the accessible area completely.
I’ve provided a few examples below.
Lab Discussion Points
1.    Before starting implementation, design your code base. Design a class that will be in charge of reading the file.
•    Make a list of methods and member variables you think it should have
2.    Design a class that, given a valid map, will traverse it.
•    Make a list of member variables and method you think it should have.
3.    Discuss how you plan to detect the need for backtracking should you reach a deadend in the map. What will variables/objects/arrays will need to be updated when you backtrack?
4.    Discuss how you plan to detect flooding all possible spaces OR running out of water
Additional Requirements
Do not use a stack object to solve the problem; use recursion.
Emailing Your Submission
Once you have created the tarball with your submission files, email it to your TA. The email subject line must look like “[EECS 268] SubmissionName”:
[EECS 268] Lab 0#
Note that the subject should be exactly like the line above. Do not leave out any of the spaces, or the bracket characters (“[” and “]”). In the body of your email, include your name and student ID.
Rubric
•    60% Correctly floods map
•    30% If possible floods until all reachable spaces are flooded
•    30% Correctly floods until out of water
•    10% Correctly detects invalid file formats
•    20% Code design
•    10% Code style and documentation
Sample Runs
map.txt
8 7
5 4
1000
HHHHHHH
H
HH HH H
H  HH H
H HHHHH
H    HH
HHHHHHH
H     H
Command line
./Lab09 map.txt
Output
Size: 8,7
Starting position: 5,4
HHHHHHH
~~~~~~H
HH~HH~H
H~~HH~H
H~HHHHH
H~~~~HH
HHHHHHH
H     H
Flood complete.
Sample Run that runs out of water
waterLimit.txt
7 7
0 4
8
HHHH HH
H
HH HH H
HH H
H HHHHH
H     H
HHHHHHH
Command line
./Lab09 waterLimit.txt
Output
Size: 7,7
Starting position: 0,4
HHHH~HH
~~~~H
HH~HH~H
HH~H
H HHHHH
H     H
HHHHHHH
Flood ran out of water.
Sample Run with bad start position
badStart.txt
6 6
10 10
6
HHHHHH

HH HH
HH
H HHHH
H    H
Command Line
./Lab09 badStart.txt
Output
Invalid starting position