Question

Java Programming Using BLUEJ

Modify the Game Of War project so that the game can be played until a user specifies quitting from the keyboard.

Hint: Add a Scanner object to the Driver class to read user  input and a loop to repeat the play method.

Driver-GameOfWar Class Edit Tools Options Driver × Compile Undo Cut Copy Paste Find... Close Source Code import java.util.Scanner; t A Driver to execute Game Of War program t@John Manz * @version (a version number or a date) public class Driver t A * Main method to begin execution 치 public static void main(String[] args) Game gamenew Game () game.play()

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import java.util.Scanner;
/**
 * Driver to execute Game of War program.
 *
 * @Jhon Manz
 * @version (a version number or a date)
 */
public class Driver
{
    /**
     * Main method to begin execution
     */
    public static void main(String[] args)
    {
        /**
         * Here we have delared a scanner variable sc.
         */
        Scanner sc = new Scanner(System.in);

        char c;

        /**
         * Do while loop will ececute until user will press N, instead of Y.
         */
        do
        {
            Game game = new Game();
            game.play();

            System.out.println("Do you want to continue, If yes press Y and if you don't want to continue press N : ");

            /**
             * here we take an character input from the user to check whether they want to continiue or quit.
             */
            c = sc.next().charAt(0);
        }
        while(c != 'N' || c == 'Y');


    }
}

Driver-GameOfWar Class Edit Tools Options Driver X Compile Undo Cut Copy PasteFind.. Close Source Code t Here we have delared a scanner variable sc Scanner sc new Scanner (System.in); char c; * Do while loop will ececute until user will press N, instead of Y do Game gamenew Game() game.play (丿, System.out.println(Do you want to continue, If yes press Y and if you dont want to continue press N: * here we take an character input from the user to check whether they want to continiue or quit 치 c- sc.next().charAt(0) while(c ! NT No changes need to be saved saved 17:38 sf ^^冊脈函[HE] ENG 04-12-2018 무

If you need more help please let us know via comments.

Add a comment
Know the answer?
Add Answer to:
Java Programming Using BLUEJ Modify the Game Of War project so that the game can be...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using Java programming: Modify the delimiter class (provided below) so that it can "incorrectly" ...

    Using Java programming: Modify the delimiter class (provided below) so that it can "incorrectly" evaluate simple parenthesized math expressions . a) ask the user for the whole expression to solve b) Solve the expression only if there is no mismatch in the delimiters. If there is a mismatch, then output an error. If there is an error, allow the user to reenter a corrected/new expression. c) The program should be able to evaluate expressions that uses only the following basic...

  • JAVA HELP FOR COMP: Can someone please modify the code to create LowestGPA.java that prints out...

    JAVA HELP FOR COMP: Can someone please modify the code to create LowestGPA.java that prints out the name of the student with the lowestgpa. In the attached zip file, you will find two files HighestGPA.java and students.dat. Students.dat file contains names of students and their gpa. Check if the code runs correctly in BlueJ or any other IDE by running the code. Modify the data to include few more students and their gpa. import java.util.*; // for the Scanner class...

  • You will write a single java program called MadLibs. java.

    You will write a single java program called MadLibs. java. This file will hold and allow access to the values needed to handle the details for a "MadLibs" game. This class will not contain a maino method. It will not ask the user for any input, nor will it display (via System.out.print/In()) information to the user. The job of this class is to manage information, not to interact with the user.I am providing a MadLibsDriver.java e^{*} program that you can...

  • (Java with Netbeans) Programming. Please show modified programming code for already given Main class, and programming...

    (Java with Netbeans) Programming. Please show modified programming code for already given Main class, and programming for code for the new GameChanger class. // the code for Main class for step number 6 has already been given, please show modified progrraming for Main class and GameCHanger class, thank you. package .games; import java.util.Random; import java.util.Scanner; public class Main { public static void main(String args[]) { System.out.println("Welcome to the Number Guessing Game"); System.out.println(); Scanner sc = new Scanner(System.in); // Get upper...

  • Java. Java is a new programming language I am learning, and so far I am a...

    Java. Java is a new programming language I am learning, and so far I am a bit troubled about it. Hopefully, I can explain it right. For my assignment, we have to create a class called Student with three private attributes of Name (String), Grade (int), and CName(String). In the driver class, I am suppose to have a total of 3 objects of type Student. Also, the user have to input the data. My problem is that I can get...

  • Modify the below Java program to use exceptions if the password is wrong (WrongCredentials excpetion). import java.util....

    Modify the below Java program to use exceptions if the password is wrong (WrongCredentials excpetion). import java.util.HashMap; import java.util.Map; import java.util.Scanner; class Role { String user, password, role; public Role(String user, String password, String role) { super(); this.user = user; this.password = password; this.role = role; } /** * @return the user */ public String getUser() { return user; } /** * @param user the user to set */ public void setUser(String user) { this.user = user; } /** *...

  • Intro to Programming in Java Elements of Programming Book Problem 1.3.25 1.3.25 .) Modify Gambler to...

    Intro to Programming in Java Elements of Programming Book Problem 1.3.25 1.3.25 .) Modify Gambler to take an extra command-line argument that specifies the (fixed) probability that the gambler wins each bet. Use your program to try to learn how this probability affects the chance of winning and the expected number of bets. Try a value of p close to 0.5 (say, 0.48) public class Gambler { public static void main(String[] args) {    int stake = Integer.parseInt(args[0]);    int...

  • read the code and comments, and fix the program by INSERTING the missing code in Java...

    read the code and comments, and fix the program by INSERTING the missing code in Java THank you please import java.util.Scanner; public class ExtractNames { // Extract (and print to standard output) the first and last names in "Last, First" (read from standard input). public static void main(String[] args) { // Set up a Scanner object for reading input from the user (keyboard). Scanner scan = new Scanner (System.in); // Read a full name from the user as "Last, First"....

  • using Data Structures using Java. Modify it to make the ADT resizable. For this ADT, the...

    using Data Structures using Java. Modify it to make the ADT resizable. For this ADT, the MAX_SIZE will not be final, but rather will be increased whenever an new item needs to be added and the array is full (ie. size==MAX_SIZE). Whenever the array needs to grow, add the lesser of: (i) half the current size, or; (ii) 50 additional. Have your ADT report its old and new maximum size whenever the resize operation is called by printing “ADT resized...

  • Modify the following given Java program. You are expected to modify the supplied Exercise1.java to print...

    Modify the following given Java program. You are expected to modify the supplied Exercise1.java to print just the last lines of each paragraph in HTML format. Copy and paste the Sample input on the console then print the Expected output. import java.util.Scanner; public class Exercise1 { /** A simple static string for HTML & table header. */ private static final String HTMLHeader = "<!DOCTYPE html>\n" + " <html>\n" + " <head>\n" + " <title>CSE: Exercise 1</title>\n" + " </head>\n" +...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT