Results 1 to 12 of 12
  1. #1
    nemoisback66 is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default Slot Machine Project

    Hi all,

    Im new to java this year and have been asked to create a small slot machine program for a project. It is a 3 reel slot machine with a few different combinations of winning. I have came across a few problems when coding this I have listed them below.

    1. The program has yet to start up and run. I keep getting these 3 errors and dont no how to fix them. This is in the main application.

    C:\Users\Andy\Desktop\Programming\SlotMachine.java :55: cannot find symbol
    symbol : method compute()
    location: class SlotMachine
    mySlot.compute();
    ^
    C:\Users\Andy\Desktop\Programming\SlotMachine.java :94: cannot find symbol
    symbol : method getwinnings()
    location: class SlotMachine
    winnings = mySlot.getwinnings();
    ^
    C:\Users\Andy\Desktop\Programming\SlotMachine.java :97: cannot find symbol
    symbol : method geteuro()
    location: class SlotMachine
    euro = mySlot.geteuro();

    This is the code i have for this part of the program.
    Java Code:
    import javabook.*;
    
    class SlotMachine{
    	public static void main(String args[]){
    
    		//Declare objects
    
    		MainWindow mWindow;
    		InputBox iBox;
    		OutputBox oBox;
    		SlotMachine mySlot;
    
    		//Create objects
    
    		mWindow = new MainWindow();
    		iBox = new InputBox(mWindow);
    		oBox = new OutputBox(mWindow);
    		mySlot = new SlotMachine();
    
    		//Show mWindow & oBox
    
    		mWindow.show();
    		oBox.show();
    
    		//Declare Variables
    
    		int euro;
    		int coin;
    		int winnings;
    		int slot1;
    		int slot2;
    		int slot3;
    
    
    
    		//Get Input
    
    		iBox.getInteger();
    		      System.out.println("Enter amount of coins to bet");
    
    			if (coin == 0){
    					System.out.println("Game has ended");
    }
    
    
    		//process
    
    
    		mySlot.compute();
    
    		if (slot1 == 1){
    			oBox.print("Cherry ");
    	}
    		else if (slot1 == 2){
    			oBox.print("Grape ");
    	}
    		else if (slot1 == 3){
    			oBox.print("Bell");
    	}
    
    
    		if (slot2 == 1){
    			oBox.print("Cherry ");
    	}
    		else if (slot2 == 2){
    			oBox.print("Grape ");
    	}
    		else if (slot2 == 3){
    			oBox.print("Bell");
    	}
    
    		if (slot2 == 1){
    			oBox.print("Cherry ");
    	}
    		else if (slot2 == 2){
    			oBox.print("Grape ");
    	}
    		else if (slot2 == 3){
    			oBox.print("Bell");
    	}
    
    
    
    
    
    		//output
    
    		winnings = mySlot.getwinnings();
    			oBox.println("You have Won");
    
    		euro = mySlot.geteuro();
    			oBox.println("Your coins in Euro");
    
    }
    }
    The other part of the program gives me 2 errors!

    1.C:\Users\Andy\Desktop\Programming\Slot.java:44: illegal start of expression
    public void setCoin(int c){
    ^
    2.C:\Users\Andy\Desktop\Programming\Slot.java:151: ';' expected
    ^
    This is the code below.
    Java Code:
    import javabook.*;
    import java.util.Random;
    
    
     class Slot{
     	private Random slotNumber = new Random();
    
    
     	//Assigning value for each symbol
    
    
    	 private final int bell =1;
    	 private final int grape =2;
    	 private final int cherry =3;
    
    	//Declare Data Members
    
    	private int PayoutMultiplier;
    	private int coin;
    	private int euro;
    
    	private int slot1;
    	private int slot2;
    	private int slot3;
    
    	//Constructor
    
    	public Slot(){
    		coin =0;
    		PayoutMultiplier =0;
    	{
    
    
    	//Set Method
    
    	public void setCoin(int c){
    		coin = c;
    }
    	public void setPayoutMultiplier(int pm){
    		payoutmultiplier = pm;
    
    }
    
    
    
    	//Get Method
    
    	public int getPayoutMultiplier(){
    		return payoutMultiplier;
    	{
    
    	public int getSlot1(){
    		return slot1;
    	{
    
    	public int getSlot2(){
    			return slot2;
    	{
    
    	public int getSlot3(){
    			return slot3;
    	{
    
    
    
    	//Compute
    
    		public void compute(){
    
    		int slot1 = slotNumber.nextInt(3) + 1;
    		int slot2 = slotNumber.nextInt(3) + 1;
    		int slot3 = slotNumber.nextInt(3) + 1;
    
    		if (slot1 == bell && slot2 == bell && slot3 == bell){
    			System.out.println("10");
    			payoutMultiplier = 10;
    	}
    		else if (slot1 == grape && slot2 == grape && slot3 == grape){
    			System.out.println("7");
    			payoutMultiplier = 7;
    	}
    
    		else if (slot1 == cherry && slot2 == cherry && slot3 == cherry){
    			System.out.println ("5"):
    			payoutMultiplier = 5;
    	}
    
    		else if (slot1 == cherry && slot2 == cherry && (slot3 == grape || slot3 == bell)){
    			System.out.println ("3");
    			payoutMultiplier = 3;
    	}
    
    		else if (slot1 == cherry && (slot2 == grape || slot2 == bell) && slot3 == cherry){
    			System.out.println ("3");
    			payoutMultiplier = 3;
    	}
    
    		else if ((slot1 == grape || slot1 == bell) && slot2 == cherry && slot3 == cherry){
    			System.out.println ("3");
    			payoutMultiplier = 3;
    	}
    
    		else if (slot1 == cherry && (slot2 == grape || slot2 == bell)  && (slot3 == grape || slot3 == bell)){
    			System.out.println ("1");
    			payoutMultiplier = 1;
    	}
    
    		else if ((slot1 == grape || slot1 == bell) && slot2 == cherry && (slot3 == grape || slot3 == bell)){
    			System.out.println ("1");
    			payoutMultiplier = 1;
    
    	}
    
    		else if ((slot1 == grape || slot1 == bell) && (slot2 == grape || slot2 == bell) && slot3 == cherry){
    			System.out.println ("1"):
    			payoutMultiplier = 1;
    
    	}
    
    		else if ((slot1 == grape || slot1 == bell) && (slot2 == grape || slot2 == bell) && (slot3 == grape || slot3 == bell)){
    			System.out.println ("No Win")
    			payoutMultiplier = 0;
    	}
    
    		else {
    			System.out.println("No Combination")
    	}
    }
    
    
    
    	//Get Method
    
    	public int getWinnings();{
    		int winnings = payoutMultiplier * coins;
    		return winnings;
    	}
    
    	double geteuro();{
    		int euro = (coins * .25);
    		return euro;
    	}
    Any help with this would be much appreciated i also have to add a loop so the program allows the player to keep using the program until they enter zero so if you could also explain were abouts in the program i am to put the loop it would be great.

    Thanks for taking the time to read this.

  2. #2
    imorio is offline Senior Member
    Join Date
    Aug 2010
    Posts
    127
    Rep Power
    0

    Default

    Java Code:
    System.out.println("No Combination")
    He probably expected an ';' after this line. Can't help you with the rest of the errors

  3. #3
    nemoisback66 is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    Thanks probably have a few errors in it. Main problem is to get it to run. Thanks

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

  5. #5
    nemoisback66 is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    Should i delete this thread and just keep it in one or the other?

  6. #6
    javajr is offline Member
    Join Date
    Aug 2010
    Posts
    5
    Rep Power
    0

    Default

    Probably
    In SlotMachine.java

    The Definition of three methods are missing . so that only the error comes.
    You missed the Definition

    In slot.java
    That contains some constructor and methods are not properly closing u are opened as "{"
    and close as "{"
    for Example You see the Line 19 on Slot.java

  7. #7
    nemoisback66 is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    Can you help me with what methods I am missing im completely lost now! I fixed the opening and closing tags.

  8. #8
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default

    Quote Originally Posted by javajr View Post
    In slot.java
    That contains some constructor and methods are not properly closing u are opened as "{"
    and close as "{"
    for Example You see the Line 19 on Slot.java

    a bunch of errors are also produced because a member is declared as PayoutMultiplier but used as payoutMultiplier. look out, java is case-sensitive.
    Last edited by j2me64; 11-17-2010 at 01:54 PM.

  9. #9
    nemoisback66 is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    Hi fixed that now getting a few different errors!
    Java Code:
    C:\Users\Andy\Desktop\Programming\Slot.java:142: <identifier> expected
    	public int .getWinnings();{
                                   ^
    C:\Users\Andy\Desktop\Programming\Slot.java:147: <identifier> expected
    	double .getEuro();
                           ^
    C:\Users\Andy\Desktop\Programming\Slot.java:149: illegal start of type
    		return Euro;
                    ^
    C:\Users\Andy\Desktop\Programming\Slot.java:149: <identifier> expected
    		return Euro;
                               ^
    C:\Users\Andy\Desktop\Programming\Slot.java:150: '}' expected

  10. #10
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default

    Java Code:
    import java.util.Random;
    
    class Slot {
    
    	public static void main(String[] args) {
    		Slot s = new Slot();
    		s.setCoin(20);
    		s.compute();
    	}
    
    	private Random slotNumber = new Random();
    
    	// Assigning value for each symbol
    
    	private final int bell = 1;
    	private final int grape = 2;
    	private final int cherry = 3;
    
    	// Declare Data Members
    
    	private int PayoutMultiplier;
    	private int coin;
    	private double euro;
    
    	private int slot1;
    	private int slot2;
    	private int slot3;
    
    	// Constructor
    
    	public Slot() {
    		coin = 0;
    		PayoutMultiplier = 0;
    	}
    
    	// Set Method
    
    	public void setCoin(int c) {
    		coin = c;
    	}
    
    	public void setPayoutMultiplier(int pm) {
    		PayoutMultiplier = pm;
    
    	}
    
    	// Get Method
    
    	public int getPayoutMultiplier() {
    		return PayoutMultiplier;
    	}
    
    	public int getSlot1() {
    		return slot1;
    	}
    
    	public int getSlot2() {
    		return slot2;
    	}
    
    	public int getSlot3() {
    		return slot3;
    	}
    
    	// Compute
    
    	public void compute() {
    
    		int slot1 = slotNumber.nextInt(3) + 1;
    		int slot2 = slotNumber.nextInt(3) + 1;
    		int slot3 = slotNumber.nextInt(3) + 1;
    
    		if (slot1 == bell && slot2 == bell && slot3 == bell) {
    			System.out.println("10");
    			PayoutMultiplier = 10;
    		} else if (slot1 == grape && slot2 == grape && slot3 == grape) {
    			System.out.println("7");
    			PayoutMultiplier = 7;
    		}
    
    		else if (slot1 == cherry && slot2 == cherry && slot3 == cherry) {
    			System.out.println("5");
    			PayoutMultiplier = 5;
    		}
    
    		else if (slot1 == cherry && slot2 == cherry
    				&& (slot3 == grape || slot3 == bell)) {
    			System.out.println("3");
    			PayoutMultiplier = 3;
    		}
    
    		else if (slot1 == cherry && (slot2 == grape || slot2 == bell)
    				&& slot3 == cherry) {
    			System.out.println("3");
    			PayoutMultiplier = 3;
    		}
    
    		else if ((slot1 == grape || slot1 == bell) && slot2 == cherry
    				&& slot3 == cherry) {
    			System.out.println("3");
    			PayoutMultiplier = 3;
    		}
    
    		else if (slot1 == cherry && (slot2 == grape || slot2 == bell)
    				&& (slot3 == grape || slot3 == bell)) {
    			System.out.println("1");
    			PayoutMultiplier = 1;
    		}
    
    		else if ((slot1 == grape || slot1 == bell) && slot2 == cherry
    				&& (slot3 == grape || slot3 == bell)) {
    			System.out.println("1");
    			PayoutMultiplier = 1;
    
    		}
    
    		else if ((slot1 == grape || slot1 == bell)
    				&& (slot2 == grape || slot2 == bell) && slot3 == cherry) {
    			System.out.println("1");
    			PayoutMultiplier = 1;
    
    		}
    
    		else if ((slot1 == grape || slot1 == bell)
    				&& (slot2 == grape || slot2 == bell)
    				&& (slot3 == grape || slot3 == bell)) {
    			System.out.println("No Win");
    			PayoutMultiplier = 0;
    		}
    
    		else {
    			System.out.println("No Combination");
    		}
    	}
    
    	// Get Method
    
    	public int getWinnings() {
    		int winnings = PayoutMultiplier * coin;
    		return winnings;
    	}
    
    	public double getEuro() {
    		euro = (coin * .25);
    		return euro;
    	}
    }

  11. #11
    nemoisback66 is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    Thanks very much for that!! It sorted the problem it now actually works!! My next problem is getting the SlotMachine.java to work with it and then also add a loop to the program so it works!! Can you point me in the right direction please??

  12. #12
    nemoisback66 is offline Member
    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Default

    These are the errors im getting! Thanks for all the help so far begining to understand wer ive went wrong by looking at ur fixed code!! If you could help me with this last bit it would be great!!!

    Java Code:
    C:\Users\Andy\Desktop\Programming\SlotMachineApp.java:55: cannot find symbol
    symbol  : method compute()
    location: class SlotMachine
    		mySlot.compute();
                          ^
    C:\Users\Andy\Desktop\Programming\SlotMachineApp.java:94: cannot find symbol
    symbol  : method getWinnings()
    location: class SlotMachine
    		Winnings = mySlot.getWinnings();
                                     ^
    C:\Users\Andy\Desktop\Programming\SlotMachineApp.java:97: cannot find symbol
    symbol  : method getEuro()
    location: class SlotMachine
    		Euro = mySlot.getEuro();
                                 ^
    Am i missing any methods? I think this could be the problem!!

Similar Threads

  1. Project in Virtual Machine
    By alex1970 in forum IntelliJ IDEA
    Replies: 0
    Last Post: 10-16-2009, 12:50 PM
  2. 32 bit machine or 64 bit machine
    By Kapil Gupta in forum Advanced Java
    Replies: 13
    Last Post: 06-24-2008, 03:29 AM
  3. How to get URL from network machine
    By Mir in forum Networking
    Replies: 1
    Last Post: 04-02-2008, 12:08 AM
  4. Getting name/ip of a machine
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-02-2008, 07:11 PM
  5. Replies: 0
    Last Post: 07-25-2007, 09:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •