import java.applet.Applet; import java.awt.*; public class mainSlots extends Applet { //RAINBOW = 0, GOLD = 1, CLOVER = 2, POT = 3, BAR = 4, FISH = 5; public Button pull; public TextField cash; private Panel main, top, boxes, bottom, arm, RtPanel, LfPanel, active; public Canvas Rt, Lf; public boxCanvas Box1, Box2, Box3; public titleCanvas title; public bottomCanvas score; public armCanvas pullPic; public Label youHave; public boolean On = true; public int spin1, spin2, spin3; public int cur1, cur2, cur3; public double money; public int xPlace, yPlace; public void init() { title = new titleCanvas(); title.resize(420, 50); money = 1.00; pullPic = new armCanvas(); pullPic.resize(60, 360); pull = new Button("Pull!"); cash = new TextField(20); cash.setEditable(false); cash.setText("$" + String.valueOf(money)); cash.setBackground(Color.white); Box1 = new boxCanvas(0); Box2 = new boxCanvas(1); Box3 = new boxCanvas(2); Box1.resize(120, 120); Box2.resize(120, 120); Box3.resize(120, 120); Box1.setBackground(Color.white); Box2.setBackground(Color.white); Box3.setBackground(Color.white); score = new bottomCanvas(); score.setBackground(Box1.DkGreen); score.resize(420, 200); youHave = new Label("You Have: "); main = new Panel(); top = new Panel(); top.add(title); top.setBackground(Color.lightGray); boxes = new Panel(); boxes.setLayout( new GridLayout(1, 3, 30, 0)); boxes.add(Box1); boxes.add(Box2); boxes.add(Box3); boxes.setBackground(Box1.DkGreen); Rt = new Canvas(); Rt.resize(1, 10); Rt.setBackground(Box1.DkGreen); Lf = new Canvas(); Lf.resize(1, 10); Lf.setBackground(Box1.DkGreen); RtPanel = new Panel(); RtPanel.add(Rt); LfPanel = new Panel(); LfPanel.add(Lf); bottom = new Panel(); active = new Panel(); active.setLayout(new FlowLayout(FlowLayout.CENTER)); active.setBackground(Box1.DkGreen); active.add(youHave); active.add(cash); active.add(pull); bottom.setLayout( new BorderLayout()); bottom.add("North", active); bottom.add("Center", score); bottom.setBackground(Box1.DkGreen); main.setLayout(new BorderLayout(30, 30)); main.add("North", top); main.add("West", LfPanel); main.add("Center", boxes); main.add("East", RtPanel); main.add("South", bottom); main.setBackground(Box1.DkGreen); arm = new Panel(); arm.add(pullPic); setLayout( new BorderLayout()); add("Center", main); add("East", arm); } public boolean action(Event e, Object o) { if(e.target == pull) { if(money > 0) { money -= .05; spin1 = 10 + (int)(Math.random() * 10); spin2 = spin1 + (int)(Math.random() * 10); spin3 = spin2 + (int)(Math.random() * 10); Box1.setNext(spin1); Box2.setNext(spin2); Box3.setNext(spin3); Box1.start(); Box2.start(); Box3.start(); showStatus("Rolling!!!!" + String.valueOf(Box2.getY())); testWin(); if(money !=0) cash.setText("$" + String.valueOf(money)); else cash.setText("ZERO ZERO ZERO ZERO"); } else { cash.setText("You have NO $Money$"); } } return true; } public void testWin() { cur1 = Box1.getCurrent(); cur2 = Box2.getCurrent(); cur3 = Box3.getCurrent(); if (cur1 == 0) { if (cur2 == 0) money += .25; else money += .10; } if (cur1 > 0 && cur1 < 5) if(cur1 == cur2 && (cur2 == cur3 || cur3 == 4)) award(cur1); } public void award(int num) { switch (num) { case 1: money += .50; break; case 2: money += .70; break; case 3: money += .90; break; case 4: money += 5.00; break; default: break; } } }