Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Code so far: import java.util.Scanner; public class V2Skeleton { public static void main(String [] args) { Scanner input = new Scanner(System.in); char [][] grid =
Code so far:
import java.util.Scanner; public class V2Skeleton { public static void main(String [] args) { Scanner input = new Scanner(System.in); char [][] grid = new char [10][10]; // initialize vampire System.out.print("Enter (i, j) for vampire: "); int newI = input.nextInt(); int newJ = input.nextInt(); Creature vampire = new Creature('V', newI, newJ); // initialize human // check whether human can move System.out.print("Would you like human to move? (0: no, 1: yes): "); int isMove = input.nextInt(); // update and display grid clearGrid(grid); vampire.display(grid); drawGrid(grid); System.out.println("Vampire at: " + vampire.getI() + " " + vampire.getJ()); // get next user command System.out.print("Enter command (0 to quit): "); int command = input.nextInt(); while (command != 0) { // while not quit clearGrid(grid); vampire.update(command); vampire.display(grid); // if vampire and human are on same square, // vampire bites human, game ends // if game does not end // human makes random move // display human on grid // if vampire and human are on same square, // human sacrificed himself, game ends drawGrid(grid); System.out.println("Vampire at: " + vampire.getI() + " " + vampire.getJ()); System.out.print("Enter command (0 to quit): "); command = input.nextInt(); } // while (command != 0) } public static void clearGrid(char [][] g) { for (int i=0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started