All pastes #241266 Raw Edit

bo liu

public java v1 · immutable
·published 2006-11-06 02:08 UTC
rendered paste body
import java.util.*;public class Guess2Db {  public static void main(String[] args) {    intro();    Scanner console = new Scanner(System.in);    game(console);  }    public static void game(Scanner console) {        Random r = new Random();    int xPoint = 0;    int yPoint = 0;    int count = 0;        double distance1;    double distance2;    int xReal = r.nextInt(11);    int yReal = r.nextInt(11);        System.out.println("Guess x and y:");    xPoint = console.nextInt();    yPoint = console.nextInt();    distance1 = Math.sqrt((xReal - xPoint)^2 + (yReal - yPoint)^2);    if (distance1 != 0) {      System.out.println("Incorrect.");      count++;    } else {      System.out.println("You got it right in " + count + " guesses!");    }            while (xReal != xPoint && yReal != yPoint) {      System.out.println("Guess x and y:");      xPoint = console.nextInt();      yPoint = console.nextInt();            distance2 = Math.sqrt((xReal - xPoint)^2 + (yReal - yPoint)^2);            if (distance1 > distance2) {        System.out.println("Colder.");      }      if (distance1 < distance2) {        System.out.println("Warmer.");      }      if (distance2 <= 1.0) {        System.out.println("Hot!");      }            distance1 = distance2;      count++;    }        System.out.println("You got it right in " + count + " guesses!");  }    public static void intro() {      System.out.println("This program is a 2-D guessing game.");    System.out.println("I will think of a point");    System.out.println("between (1, 1) and (10, 10)");    System.out.println("and give hints until you guess it.");  }}