Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Are you old applet, an applet which may tell yo uthe sad truth of your age.
- Max Adamski 10/23/14 */
- import java.awt.*;
- import java.applet.Applet;
- import java.awt.event.*;
- public class mastermindtut extends Applet implements ActionListener
- { //Declaration section
- int pageCt = 1;
- String output = "";
- Button nextBtn = new Button("Next");
- Button backBtn = new Button("Back");
- Button endBtn = new Button("End");
- public void init()
- {
- this.setLayout (null);
- backBtn.setBounds(50,450,100,50);
- backBtn.addActionListener (this);
- this.add(backBtn);
- endBtn.setBounds(160,450,100,50);
- endBtn.addActionListener (this);
- this.add(endBtn);
- nextBtn.setBounds(270,450,100,50);
- nextBtn.addActionListener (this);
- this.add(nextBtn);
- backBtn.setVisible(false);
- }
- public void actionPerformed(ActionEvent e) // makes applet do something when clicked.
- {
- if( e.getSource() == nextBtn ) //output digits
- {
- pageCt = pageCt+1;
- }
- if( e.getSource() == backBtn ) //output digits
- {
- pageCt = pageCt-1;
- }
- if( e.getSource() == endBtn ) //output digits
- {
- pageCt = 4;
- }
- repaint();
- }
- Font font1 = new Font("Calibri",5,25);
- Font font2 = new Font("Calibri",5,40);
- Font font3 = new Font ("Calibri",5,15);
- Font font4 = new Font ("Calibri",5,60);
- public void paint(Graphics g) // Outputs on screen
- {
- if(pageCt==1)
- {
- g.setFont(font1);
- g.setColor(Color.blue);
- g.drawString("Welcome to the",100,100);
- g.setFont(font2);
- g.drawString("Master Mind Tutorial!",110,140);
- }
- if (pageCt==2)
- {
- backBtn.setVisible(true);
- g.setFont(font4);
- g.setColor(Color.blue);
- g.drawString("How to play!",80,60);
- g.setFont(font3);
- g.drawString("-For each guess a black score peg indicates that one of your pegs is the right color in the right position.",20,400);
- g.drawString("-A gray score peg indicates that one of your pegs is the right color in the wrong position.",20,420);
- g.drawString("-Use the feedback to track down the correct colors.",20,440);
- g.setFont(font1);
- g.drawString("My colors:",10,120);
- g.drawString("Your guess:",10,170);
- g.setColor(Color.red);
- g.fillOval(150,150,30,30);
- g.setColor(Color.blue);
- g.fillOval(200,150,30,30);
- g.setColor(Color.yellow);
- g.fillOval(250,150,30,30);
- g.setColor(Color.yellow);
- g.fillOval(150,100,30,30);
- g.setColor(Color.blue);
- g.fillOval(200,100,30,30);
- g.setColor(Color.red);
- g.fillOval(250,100,30,30);
- g.setColor(Color.gray);
- g.fillOval(150,200,30,30);
- g.fillOval(200,200,30,30);
- g.setColor(Color.black);
- g.fillOval(250,200,30,30);
- }
- if (pageCt==3)
- {
- g.setFont(font4);
- g.setColor(Color.blue);
- g.drawString("How to play!",80,60);
- g.setFont(font1);
- g.drawString("(Continued)",80,100);
- g.drawString("- I will only use each color once.",20,150);
- g.drawString("- Each time you guess, the pegs will let you know",20,190);
- g.drawString(" how close you are.",20,210);
- g.drawString("- Each puzzle will have 3 random colors.",20,250);
- g.drawString("- You lowest number of guesses is your goal.",20,290);
- }
- if (pageCt==4)
- {
- g.setFont(font2);
- g.setColor(Color.blue);
- g.drawString("Thank you for",10,50);
- g.drawString("for reading the",40,90);
- g.drawString("Master Mind",70,130);
- g.drawString("tutorial",140,160);
- g.setFont(font3);
- g.drawString("Written by Max adamski",100,500);
- backBtn.setVisible(false);
- endBtn.setVisible(false);
- nextBtn.setVisible(false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement