This code uses the Random class to generate a random number up to 100.
You can change the 100 value to any interger you wish.
Printable View
This code uses the Random class to generate a random number up to 100.
You can change the 100 value to any interger you wish.
PHP Code:* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package unogame;
import java.util.*;
import java.lang.*;
import java.awt.*;
/**
*
* @author Xyn
*/
public class UNOGame {
static int ar;
int counter=0;
static int winCount= 0;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("Welcome to Under or Over game. Your opponnents number will be displayed and you have to go over or under it.");
for(int i=1; i<6; i++) {
double cop = new Random() .nextInt(100) +1;
double plp = new Random() .nextInt(100) +1;
System.out.println(" The computers number is " + cop + " .") ;
Scanner keyboard = new Scanner(System.in);
String pick = keyboard.next();
unofile uno = new unofile();
if (pick.equals("over")) {
if (cop>plp) {
System.out.println("You win that round!");
winCount++;
}}
if (pick.equals("under")) {
if (cop<plp) {
System.out.println("You lose that round!");
}}
if (pick.equals("over")) {
if (cop<plp) {
System.out.println("You win that round!");
winCount++;
}}
if (pick.equals("under")) {
if (cop>plp) {
System.out.println("You lose that round!");
}}
System.out.print("Your number was ");
System.out.print(plp + "." );
}
unofile uno = new unofile();
uno.counterWin = winCount;
uno.writeWall();
}
}
Theres a sample of it in use. ((NOTE: POORLY CONSTRUCTED PROGRAM)