Advertisement
mti

Moottori.java

mti
Feb 2nd, 2021 (edited)
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class Moottori {
  4.   private int loppu;
  5.   private int oikeaVastaus;
  6.   private int vastauksia;
  7.   private Random rnd;
  8.  
  9.   public Moottori(int loppu) {
  10.     this.loppu = loppu;
  11.     this.rnd = new Random();
  12.   }
  13.  
  14.   public void arvoUusi() {
  15.     this.oikeaVastaus = this.rnd.nextInt(this.loppu)+1;
  16.     this.vastauksia = 0;
  17.   }
  18.  
  19.   public int tarkistaVastaus(int vastaus) {
  20.     this.vastauksia++;
  21.     return vastaus - this.oikeaVastaus;
  22.   }
  23.  
  24.   public int getVastauksia() {
  25.     return this.vastauksia;
  26.   }
  27.  
  28.   public int getOikeaVastaus() {
  29.     return this.oikeaVastaus;
  30.   }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement