Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Everytime I go to execute my code I am getting 7 errors. Please tell me how I could possibly fix the following code: import java.awt.*;

Everytime I go to execute my code I am getting 7 errors. Please tell me how I could possibly fix the following code:

import java.awt.*;

public class Roulette { public static void main(String[] args) { new Roulette(); } class addLabel{ lMoney = addLabel("Money",40,40,60,30,this); } class addTextField { tMoney = addTextField("",100,40,100,30,this); } class addButton { bBet = addButton("Bet",40,70,80,30,this); } class addButton { bSpin = addButton("Spin",120,70,80,30,this); } class addTextField { tBet = addTextField("",40,100,80,40,this); } class addTextField { tChoice = addTextField("",40,140,80,40,this); } class addTextField { tNumber = addTextField("",120,100,80,80,this); } int money = 1000; int bet = 0; int betting = 0; String choice = ""; public void actions(Object source,String command) { if(source == bBet) { makeBet(); } else if (source == bSpin) { spin(); } } public Roulette() { setTitle("Robinson Roulette"); setSize(300,250); setBackground(Color.green); tNumber.setFont(new Font("Times New Roman",0,50)); tNumber.setForeground(Color.white); tNumber.setBackground(Color.green); tBet.setFont(new Font("Times New Roman",0,30)); tChoice.setFont(new Font("Times New Roman",0,30)); tMoney.setFont(new Font("Times New Roman",0,16)); tMoney.setText(money + ""); }

public void makeBet() { do { betting = inputInt("How much do you want to bet?"); } while (betting < 0 || betting > money); bet = betting; { while (money > 0) { System.out.print("You have $" + money + ". Place your bet: " ); int bet = console.nextInt(); while (bet > money) { System.out.println("You bet too much: $" + bet); System.out.print("You have $" + money + ". Place your bet: " ); int bet = console.nextInt(); } } } choice = input("Betting on : Red, Black, or a Number"); tBet.setText(betting + ""); tChoice.setText(choice); } public int rand(int lowest, int highest) { return (int)(Math.floor(Math.random()*(highest-lowest+1)+lowest)); }

public void spin() { long start = System.currentTimeMillis(); do { int num = rand(0,36); tNumber.setText( num + ""); if (num == 0) { tNumber.setBackground(Color.green); } else if ( ((num-1)/3) % 2 == 0 ) { tNumber.setBackground(Color.red); } else { tNumber.setBackground(Color.black); } repaint(); } while (System.currentTimeMillis()-start < 3000); money = money + checkWinner(); tMoney.setText(money + ""); } public int checkWinner() { if ((tNumber.getBackground() == Color.red) && (tChoice.getText().equals("Red"))) { return bet; } else if ((tNumber.getBackground() == Color.black) && (tChoice.getText().equals("Black"))) { return bet; } else if (tNumber.getText().equals( tChoice.getText() ) ) { return 36*bet; } else { return -bet; } } public void pause(long millis) { long start = System.currentTimeMillis(); do { } while (System.currentTimeMillis() - start < millis) ; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB.NET Databases

Authors: Thearon Willis

1st Edition

1594864217, 978-1594864216

More Books

Students also viewed these Databases questions

Question

4. What action should Cherita Howard take and why?

Answered: 1 week ago