Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
construct a Bulls and Cows program for my intro Java class. This program needs to perform the basic functions of the game (determining how many cows there are and how many bulls there are and tell the player when they win), but it also needs to offer the option to play again and record top score, low score, and average score over the games played in one session. I have the basic code down, but I'm having a hard time figuring out how to give the option to play again and print the high, low, and average scores. Can anyone help? My code is below.
public class Tester{public static void main (String[] args){Game g = new Game();g.play();}}public class Game{int turns = 0;Player p = new Player();Oracle o = new Oracle();public void play (){String generated_number = o.generateNumber();System.out.println(" generated_number is " + generated_number);int[] a= {0,0};while(a[0]<4){String Guessed_number = p.makeGuess();// a[0] represents bulls and a[1] represents cows.// we need this information to be returned from compare function// so used array here.// array is the only way to return multiple values from function.o.compare(generated_number,Guessed_number, a);System.out.println(a[0] + " bull(s) and " + a[1] + " cow(s)");turns++;}System.out.println("Correct! You took " + turns + " guesses.");}}import java.util.Scanner;public class Player{String yourGuess;public Player(){}public String makeGuess(){Scanner in = new Scanner(System.in);System.out.println("Guess a four-digit number");return in.next();}}import java.util.Random;public class Oracle{public Oracle() {}public String generateNumber(){Random generator = new Random();int a = 0;int b = 0;int c = 0;int d = 0;while(a==b||a==c||a==d||b==c||b==d||c==d){a = generator.nextInt(10);b = generator.nextInt(10);c = generator.nextInt(10);d = generator.nextInt(10);}String generatedNumber = "" +a+b+c+d;return generatedNumber;}public static void compare(String generatedNumber, String yourGuess, int[] a){a[0] = a[1]=0;for (int i=0; i<4; i++){for (int j=0; j<4; j++){if (generatedNumber.charAt(i)==yourGuess.charAt(j)){if (i==j){a[0]++;}else{a[1]++;}}}}}}
develop a program that will handle a Golfer and his scores. The program will be comprised of two classes: a Golfer class that will manage all the golfer's scores and a Score class.This is a class designed to represent a golfer including his name, hom..
1. What is Server-side and Client-side scripting? Explain the differences between server-side and client - side scripting languages. Please provide 3 advantages and disadvantages of each. Please provide applicable references in APA style
UML Exercise: Automated Teller Machine (ATM), 1. To allow authorized card holders to make transactions, Brief Summary of Requirements:
Write a program that uses a 2-D array to store the highest and lowest temperatures for each montjh of the year. The program should output the average high, average low, and highest and lowest temperatures of the year. Your program must consist of ..
Write a java applet (not a java application program) for costco gas station. The applet will first ask you whether you are a costco customer, then the grade of gas you want to use.
write java code to read integers from an input file and write only the odd numbers to an output file. the two file names will be provided on the command line as the input file followed by the output file.
write a program that reads in a list of numbers from a file and adds up all those numbers. You may hard code in the name of the file, allowing the user to input the filename is not required
This exercise explains you the process of testing and enhancing Line Item application. Open LineItemApp, Validator, Product, LineItem, and ProductDB classes that are in the c:java1.6ch06LineItem directory and review this code.
A JSP expression can contain any Java expression that evaluates to a
Write a Java program that declares an array alpha of 50 elements of type double. Initialize the array so that the first 25 elements are equal to the square of the index variable, and the last 25 elements are equal to three times the index variable. O..
Design decision marks are based on how you implemented our programs/classes.
Write down java program for real estate agent. Program must perform the following tasks: ask users for average house price for the each of past 5 years for single family residence of 1500 square feet.
Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!
whatsapp: +1-415-670-9521
Phone: +1-415-670-9521
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd