I'm writing a program in java called Sokoban. I'm pretty far in, but there are a few methods that I have no idea where to go from where I am now.
Method 1:
/**
* Moves a box on the board.
*
* Step 1: Use your checkDelta method to check that the move is valid. Recall that there are 2
* characters that can represent a box. Step 2: Use your togglePos method to correctly change
* the character at the new position to the appropriate box character. Step 3: Again use your
* togglePos method to correctly change the character at pos to the the appropriate character
* without a box.
*
* @param board The current board.
* @param pos The position to change. A length 2 array, where index 0 is the row and index 1 is
* the column.
* @param delta The move distance. A length 2 array, where index 0 is the change in row and
* index 1 is the change in column.
* @return The return value of checkDelta if less than 1. Otherwise 1.
*/
public static int shiftBox(char[][] board, int[] pos, int[] delta) {
char[] valid = {Config.BOX_CHAR, Config.BOX_GOAL_CHAR};
if (checkDelta(board, pos, delta, valid) == 1) {
char val = Config.GOAL_CHAR;
char opt1 = Config.BOX_GOAL_CHAR;
char opt2 = Config.BOX_CHAR;
togglePos(board, pos, val, opt1, opt2);
opt1 = Config.GOAL_CHAR;
opt2 = Config.BOX_CHAR;
togglePos(board, pos, val, opt1, opt2);
return 1;
}
else {
return (checkDelta(board, pos, delta, valid));
}
return -99;
}
//incomplete
Method 2:
/**
* Processes a move of the worker step-by-step.
*
* Go through the delta step-by-step, calling doMove for each step. That is, if the delta is {0,
* -3}, your method should call doMove three times with an argument of {0, -1} for the delta
* parameter of doMove. Or, if the delta is {6, 0}, it would call the doMove six times with an
* argument of {1, 0} for the delta parameter of the doMove method.
*
* During the processing of the move, if ever a call to doMove returns a value less than 1, your
* method should stop processing and return that value.
*
* Note: You can assume that one of the cells of delta will be 0.
*
* @param board The current board.
* @param pos The position to change. A length 2 array, where index 0 is the row and index 1 is
* the column.
* @param delta The move distance. A length 2 array, where index 0 is the change in row and
* index 1 is the change in column.
* @return If both of the cells of delta are 0, return 0. If the call to doMove returns a value
* less than 1, return that value. Otherwise, return 1.
*/
public static int processMove(char[][] board, int[] pos, int[] delta) {
return -99;
}
Method 3:
/**
* Moves the worker on the board.
*
* Step 1: Use your checkDelta method to check that the move is valid. Recall that there are 2
* characters that can represent the worker. Step 2: If checkDelta returns -5, use your shiftBox
* method to move the box by delta before moving the worker. Step 3: Use your togglePos method
* to correctly change the character at the new position to the appropriate worker character.
* Step 4: Again use your togglePos method to correctly change the character at pos to the the
* appropriate character without a worker. Step 5: Update the position of the worker in pos.
*
* @param board The current board.
* @param pos The position to change. A length 2 array, where index 0 is the row and index 1 is
* the column.
* @param delta The move distance. A length 2 array, where index 0 is the change in row and
* index 1 is the change in column.
* @return If checkDelta returns a value less than 1 that is not -5, return that value. If
* checkDelta returns -5 and shiftBox returns a value less than 0, return 0. Otherwise,
* return 1.
*/
public static int doMove(char[][] board, int[] pos, int[] delta) {
// FIX ME
return -99;
}
Any help would be greatly appreciated!!!
I'm writing a program in java called Sokoban. I'm pretty far in, but there are a...
Hello I am having trouble with a connectFour java program. this issue is in my findLocalWinner method, it declares a winner for horizontal wins, but not for vertical. if anyone can see what im doing wrong. public class ConnectFour { /** Number of columns on the board. */ public static final int COLUMNS = 7; /** Number of rows on the board. */ public static final int ROWS = 6; /** Character for computer player's pieces */ public static final...
Maze Solving with Stacks Problem Statement Consider a maze made up of rectangular array of squares, such as the following one: X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X Figure...
Can someone help me with the writing of this code please? public static int promptInt(Scanner input, String prompt, int min, int max) { return 0; //TODO replace } /** * Returns the index within arr of the first occurrence of the specified character. * If arr is null or 0 length then return -1. For all arrays, don't assume a length * but use the array .length attribute. * @param arr The array to look...
I am unsure how to add the following methods onto this code?? please help - rowValuesIncrease(int[][] t) A method that returns true if from left to right in any row, the integers are increasing, otherwise false. - columnValuesIncrease(int[][] t) A method that returns true if from top to bottom in any column, the integers are increasing, otherwise false. - isSetOf1toN(int[][] t) A method that returns true if the set of integers used is {1, 2, . . . , n}...
Here is the indexOf method that I wrote: public static int indexOf(char[] arr, char ch) { if(arr == null || arr.length == 0) { return -1; } for (int i = 0; i < arr.length; i++) { if(arr[i] == ch) { return i; } } return -1; ...
Anybody Know how to Solve this Problem Thank you very much // ***** 1. This method has been coded as an example /** Fills the array with random numbers between 50 and 80 * The instance variable named intArray is the integer array to be * filled with values */ public void fillValues( ) { Random rand = new Random( ); for ( int row = 0; row < intArray.length; row++ ) { System.out.print( row + "\t" ); for (...
Hi I need help with a java program that I need to create a Airline Reservation System I already finish it but it doesnt work can someone please help me I would be delighted it doesnt show the available seats when running the program and I need it to run until someone says no for booking a seat and if they want to cancel a seat it should ask the user to cancel a seat or continue booking also it...
I need help with this one method in java. Here are the guidelines. Only public Employee[] findAllBySubstring(String find). EmployeeManager EmployeeManager - employees : Employee[] - employeeMax : final int = 10 -currentEmployees : int <<constructor>> EmployeeManager + addEmployee( type : int, fn : String, ln : String, m : char, g : char, en : int, ft : boolean, amount : double) + removeEmployee( index : int) + listAll() + listHourly() + listSalary() + listCommision() + resetWeek() + calculatePayout() :...
#include <stdio.h> #include <stdlib.h> #include <string.h> struct game_piece { }; struct game_board { }; void game_piece_init_default(struct game_piece* piece) { } void game_piece_init(struct game_piece* piece, char* new_label) { } char* game_piece_get_label(struct game_piece* piece) { return ""; } char* game_piece_to_string(struct game_piece* piece) { return ""; } void game_board_init(struct game_board* game_board, int rows, int cols) { } int game_board_is_space_valid(struct game_board* game_board, int row, int col) { return 0; } int game_board_add_piece(struct game_board* game_board, struct game_piece* piece, int row, int col) { return 0;...
Programming project in Java: You are allowed to use the following methods from the Java API: class String length charAt class StringBuilder length charAt append toString class Character any method Create a class called HW2 that contains the following methods: 1. isAlphabeticalOrder takes a String as input and returns a boolean: The method returns true if all the letters of the input string are in alphabetical order, regardless of case. The method returns false otherwise. Do not use arrays to...