Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using c++, use a 4x4 maze(for ex this as input: THE NUMBER OF ROOMS DOORS LISTED

ID: 3865480 • Letter: U

Question

Using c++, use a 4x4 maze(for ex this as input:

THE NUMBER OF ROOMS
DOORS LISTED IN ORDER: NORTH, EAST, SOUTH, WEST FOR EACH ROOM: 0 = NO DOORS

0 = 0100
1 = 0111
2 = 0111
3 = 0001
4 = 0100
5 = 1011
6 = 1010
7 = 0010
8 = 0110
9 = 1001
10 = 1100
11 = 1001
12 = 1100
13 = 0101
14 = 0101
15 = 0001 ),

Create 3 functions,

1st function uses an adjacency linked list to represent the graph

2nd fuction Prints out vertices (room numbers) on the shortest entry-exit path.

3rd fuction Prints out all verticies (room numbers) on all possible entry-exit path.

Explanation / Answer

import java.util.Random;

public enum Direction {
NORTH, EAST, SOUTH, WEST;
private static Random rnd = new Random();

static public Direction randomDirection() {
return Direction.values()[rnd.nextInt(4)];
}

  
public Direction rotate90() {
return values()[(ordinal() + 1) % 4];
}

  
public Direction rotate180() {
return values()[(ordinal() + 2) % 4];
}

  
public Direction rotate270() {
return values()[(ordinal() + 3) % 4];
}

public Boolean isHorizontal() {
return this == EAST || this == WEST;
}

public Boolean isVertical() {
return this == NORTH || this == SOUTH;
}

public int dx(int steps) {
if (this == EAST) {
return steps;
}
if (this == WEST) {
return -steps;
}
return 0;
}

public int dy(int steps) {
if (this == NORTH) {
return steps;
}
if (this == SOUTH) {
return -steps;
}
return 0;
}

public int forwards_x(int n) {
if (this == EAST) {
return n + 1;
}
if (this == WEST) {
return n - 1;
}
return n;
}

public int forwards_y(int n) {
if (this == NORTH) {
return n + 1;
}
if (this == SOUTH) {
return n - 1;
}
return n;
}

public int backwards_x(int n) {
if (this == EAST) {
return n - 1;
}
if (this == WEST) {
return n + 1;
}
return n;
}

public int backwards_y(int n) {
if (this == NORTH) {
return n - 1;
}
if (this == SOUTH) {
return n + 1;
}
return n;
}

public int left_x(int n) {
if (this == NORTH) {
return n - 1;
}
if (this == SOUTH) {
return n + 1;
}
return n;
}

public int left_y(int n) {
if (this == EAST) {
return n + 1;
}
if (this == WEST) {
return n - 1;
}
return n;
}

public int right_x(int n) {
if (this == NORTH) {
return n + 1;
}
if (this == SOUTH) {
return n - 1;
}
return n;
}

public int right_y(int n) {
if (this == EAST) {
return n - 1;
}
if (this == WEST) {
return n + 1;
}
return n;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote