public class SlotMachine{

  protected int winFrequency;
  protected int jackpot;
  protected String name;

  public SlotMachine( String name, int winFrequency){
  	this.name = name;
  	this.winFrequency = winFrequency;
  	this.jackpot = (int)winFrequency/2;

  }

  public int getWinFrequency(){
  	return winFrequency;
  }

  public void printMachine(){
  	System.out.println("Playing "+name+" with a jackpot of "+jackpot+" and a 1 in "+winFrequency+" chance of winning.");

  }

  public boolean machineWins(){
	//calculate if the machine won
	int randomValue = (int) (Math.random()*100)%winFrequency;
	if (randomValue == 0) {
	  	return true;
	}else{
		return false;
	}
  }

  public int play(){
  //display machine name, jackpot, winFrequency
  printMachine();

  	//calculate if the machine won
  if (machineWins()) {
  		System.out.println("You won "+jackpot+ " token(s)!");
  		return jackpot;
  	}else{
  		System.out.println("Sorry, you lost.");
  		return 0;
  	}
  }

  public static void main(String args[]){
        SlotMachine m1 = new SlotMachine ("pinball",10);

        for (int i = 0; i < m1.getWinFrequency(); i++){
        	 int a = m1.play();
        	 System.out.println("Result: "+a);
        }
  }
}