The operator > is undefined for the argument type(s) java.util.Random, java.util.Random -


i trying create horse race betting game. i'm having trouble comparing values of horses each other see 1 wins.

in if statement try compare value of horse1 value of horse2 , horse3. error of: operator > undefined argument type(s) java.util.random, java.util.random

    import java.util.scanner;  import java.util.random;  public class runhorsegame  {  public static void main(string[] args)  { // todo auto-generated method stub  //variables     string name;     float bal;     float bet;     boolean nextrace;     int racechoice;     int startrace;      random horse1 = new random(100);     random horse2 = new random(100);     random horse3 = new random(100);     random horse4 = new random(100);     random horse5 = new random(100);     random horse6 = new random(100);     random horse7 = new random(100);      scanner input = new scanner(system.in);  //welcome screen     system.out.println("welcome horse racing!");     system.out.println("please enter name:");     name = input.nextline();     system.out.println("welcome " + name + ", have balance of $200!");  //create loop repeat races when 1 finishes (keep balance)     nextrace = true;     while (nextrace == true)     {         bal = 200;  //give race options         system.out.println("please select race       enter:");         system.out.println("press 1 enter: 3 horse race");         system.out.println("press 2 enter: 5 horse race");         system.out.println("press 3 enter: 7 horse race");  //create each race //each horse has randomizer //highest number wins race          racechoice = input.nextint();         switch(racechoice)         {             case 1:                 system.out.println("you have entered 3 horse race!");                 system.out.println("how bet?");                 bet = input.nextfloat();                 system.out.println("you have bet " + bet + " dollars.");                 bal =- bet;                 system.out.println("press 1 start.");                 system.out.println("press 2 go race selection.");                  startrace = input.nextint();                 switch(startrace)                 {                 case 1:                       if(horse1 > horse2 && horse1 > horse3)                     {                      }                      break;                  case 2:                     nextrace = false;                     break;                 }                   break;             case 2:                 break;             case 3:                 break;             default:                 break;           }          nextrace = true;      } } } 

use following:

    random randomgenerator = new random();          int horse1 = randomgenerator.nextint(100);         int horse2 = randomgenerator.nextint(100); //and on... 

as (@ajb) rightly said that: random not random number. when assigning horse data type should int , not random , should use method of random shown above desired random number.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -