X hits on this document

112 views

0 shares

0 downloads

0 comments

46 / 46

© S. Uchitel, 2004

46

Putting it all together (3)

package uk.ac.ic.doc.su2.games;

import java.util.Random;  

import kenya.io.InputReader;

public class Guess {

//Implements the “guess-what-number-I’m-thinking of” game

public static void main(String [] args) {

 Random generator = new Random();

 int number = generator.nextInt(10)+1;

//Pick a number randomly between 1 and 10

 System.out.println(“Take a guess (1 to 10)”);

 if (number == InputReader.readInt())

System.out.println(“You win”);

 else

System.out.println("It was " + number + ", tough Luck");

}

}

Are these objects?

Where/when were they created?

There are still a number

of things we need

to see to fully

comprehend this program...

(next lecture notes)

Document info
Document views112
Page views112
Page last viewedWed Dec 07 16:42:10 UTC 2016
Pages46
Paragraphs816
Words2901

Comments