Home » Computer Science Question

Computer Science Question

Maze – Starter Code

Tests

.

java – Test Methods

Maze – Starter Code

Tests.java – Test Methods

https://drive.google.com/drive/folders/

1

I8cvFjGW7M…

Purpose

As a reminder, the purpose of this task is to apply the programming skills you have acquired to a practical and in-depth project. In this assignment, you will practice designing and using methods, strings, and

2

D arrays.

If you are having trouble getting started, review the material and think about how you can use each concept to accomplish your goals. We recommend reviewing the following sections:

4.

0

: Defining and Using Methods

;

4.1: Methods That Return Values

;

5.3: Multidimensional Arrays

;

5.4: Traversing 2D Arrays

; and

6.1: Comparing and Manipulating Strings

.

Task

OUTLIER ODYSSEY

Your ultimate goal is to build a game called Outlier Odyssey. In this game, a player will navigate a two-dimensional map from one corner to another with limited resources while encountering hazards. During each part of the project, you will build an aspect of the game. Code from a given part may be reused in the following parts.

PART TWO: MAZE

For this assignment, you will complete a game where a player moves from the top left-hand corner of a 2D board to the bottom right-hand corner without running out of health. To accomplish this, you will place hazards in the maze, check player movement validity, and develop player-board interaction. This assignment is expected to take 4-6 hours.

Running the Game

The maze is a 2D String array. The game will start with a reserved cell for the player (P) and one random cell containing a magical gem (GEM)! Every other cell will be randomly assigned to one of the following hazards: wolf, bear, elk, or hare.

The player starts in the top-left corner with 50 health and must travel to the bottom-right corner without running out of health. For each turn, the player can move up, down, left, or right. After selecting a direction, the player is given a preview of the hazard in the chosen cell. Then, they can confirm the move or opt out and choose a new direction.

As the player traverses the maze, their health changes according to the hazards they reach. Once the player has visited a cell, the cell value changes to “X”—the hazard has been neutralized and the player can revisit the cell without any change in health.

The game ends when the player reaches the bottom right-hand corner of the maze or when they run out of health!

Implementation

You will be responsible for completing three methods: init(), validMove(), and makeMove(). Additional methods draw

Boar

d() and runGame() have been completed for you. We have provided a second file, Tests.java, that can provide feedback on the init() and validmove() methods. You do not need to make any revisions to or submit Tests.java! To use the tests, make sure Tests.java is uploaded to your Repl.it. Then, uncomment the method calls in the main method. When you are ready to test all three methods, use runGame() and compare your output to the

sample run

.

Note: Tests.java is intended to help catch major issues. A successful test does not guarantee full credit.

METHOD ONE: init()

The init() method initializes the game board. It accepts a 2D String array as an argument and modifies that array directly to add values. The board is initialized in three steps:

  1. Randomize placement of a wolf ( “

    Wolf

    ), boar (

    “Boar”

    ), elk (

    Elk

    ), or hare (

    Hare

    ) for every cell

  2. Reserve the top-left board square for the player
  3. Randomly place a gem (“GEM”) in one non-player square

Steps 2 and 3 have been completed for you. To finish the method, add code to randomly place hazards. For each cell, use the

useful code snippets

to generate a random number between 0 and 4. Then, assign the cell to a hazard based on the randomly generated number based on the table below. Make sure to capitalize the first letter of each hazard!

012

String

“Wolf””Boar””Elk””Hare”

Randomly generated number 3 or 4
Hazard

METHOD TWO: validMove()

validMove() ensures the player is not trying to move out of the maze (out of the bounds of the 2D array). It returns a 1D array using the following logic:

  • Accept a char representing the direction the user wants to go (‘l’ for left, ‘r’ for right, ‘u’ for up, ‘d’ for down) as well as:The 2D String board arrayThe current player positionA 1D array that stores the coordinates of the next move
  • Check the current player location on the board to decide if the requested move is valid (is within the bounds of the board)
  • Modify the 1D array nextCell to:The coordinates for the next cell if the move is valid{-1, -1} if the move is not valid

METHOD THREE: makeMove()

Once a move has been validated, makeMove() implements the player movement. This is a more complex version of the player movement from

Gem

Run! makeMove() should complete three tasks:

  1. Change the String in the current player cell (the cell the player is leaving) to “X”
  2. Update the player position to the nextCell coordinates
  3. Return an int corresponding to the health cost of the new cell depending on the hazard it contains; this value can be negative or positive according to the following table:
HazardWolfBoarElkHareGem

0

Already visited
Health -20 -10 -5 +10 x 100

Criteria

You will be graded on the criteria in the rubric linked below. The purpose of this rubric is to help you understand the expectations for the assignment and improve your work. Before beginning the assignment, read the rubric to understand the criteria you will be graded on. Before you submit your assignment, use the rubric as a guide and test your program.

Tips and Tricks

Start early and take breaks. Fresh eyes are the best for debugging.

Use our useful code snippets. This project requires you to work with some external tools. You do not need to work these out for yourself!

Work one step at a time! Tackle each step in order. This assignment has three methods; take it slow and finish one before starting the next.

Test frequently and repeatedly. A small, early issue can cause big problems later.

Ask for help when you need it. If you are stuck, reach out to your instructor or use the discussion boards.

Want to keep going? Try some

extra challenges

! Make sure your submitted code does not include any of these extra implementations.

STARTER FILE(S): Maze – Starter Code.Tests.java – Test Methods.That’s what I did for part Part 1:. https://drive.google.com/drive/folders/1I8cvFjGW7M…

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Order your essay today and save 30% with the discount code ESSAYHELP