Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.52 KB | None | 0 0
  1. /* Are you old applet, an applet which may tell yo uthe sad truth of your age.
  2. Max Adamski 10/23/14 */
  3. import java.awt.*;
  4. import java.applet.Applet;
  5. import java.awt.event.*;
  6. public class mastermindtut extends Applet implements ActionListener
  7. { //Declaration section
  8. int pageCt = 1;
  9. String output = "";
  10. Button nextBtn = new Button("Next");
  11. Button backBtn = new Button("Back");
  12. Button endBtn = new Button("End");
  13. public void init()
  14. {
  15. this.setLayout (null);
  16.  
  17. backBtn.setBounds(50,450,100,50);
  18. backBtn.addActionListener (this);
  19. this.add(backBtn);
  20.  
  21. endBtn.setBounds(160,450,100,50);
  22. endBtn.addActionListener (this);
  23. this.add(endBtn);
  24.  
  25. nextBtn.setBounds(270,450,100,50);
  26. nextBtn.addActionListener (this);
  27. this.add(nextBtn);
  28.  
  29. backBtn.setVisible(false);
  30. }
  31.  
  32.  
  33. public void actionPerformed(ActionEvent e) // makes applet do something when clicked.
  34. {
  35. if( e.getSource() == nextBtn ) //output digits
  36. {
  37. pageCt = pageCt+1;
  38. }
  39. if( e.getSource() == backBtn ) //output digits
  40. {
  41. pageCt = pageCt-1;
  42. }
  43. if( e.getSource() == endBtn ) //output digits
  44. {
  45. pageCt = 4;
  46. }
  47. repaint();
  48. }
  49. Font font1 = new Font("Calibri",5,25);
  50. Font font2 = new Font("Calibri",5,40);
  51. Font font3 = new Font ("Calibri",5,15);
  52. Font font4 = new Font ("Calibri",5,60);
  53. public void paint(Graphics g) // Outputs on screen
  54. {
  55. if(pageCt==1)
  56. {
  57. g.setFont(font1);
  58. g.setColor(Color.blue);
  59. g.drawString("Welcome to the",100,100);
  60. g.setFont(font2);
  61. g.drawString("Master Mind Tutorial!",110,140);
  62. }
  63. if (pageCt==2)
  64. {
  65. backBtn.setVisible(true);
  66. g.setFont(font4);
  67. g.setColor(Color.blue);
  68. g.drawString("How to play!",80,60);
  69. g.setFont(font3);
  70. 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);
  71. g.drawString("-A gray score peg indicates that one of your pegs is the right color in the wrong position.",20,420);
  72. g.drawString("-Use the feedback to track down the correct colors.",20,440);
  73. g.setFont(font1);
  74. g.drawString("My colors:",10,120);
  75. g.drawString("Your guess:",10,170);
  76. g.setColor(Color.red);
  77. g.fillOval(150,150,30,30);
  78. g.setColor(Color.blue);
  79. g.fillOval(200,150,30,30);
  80. g.setColor(Color.yellow);
  81. g.fillOval(250,150,30,30);
  82. g.setColor(Color.yellow);
  83. g.fillOval(150,100,30,30);
  84. g.setColor(Color.blue);
  85. g.fillOval(200,100,30,30);
  86. g.setColor(Color.red);
  87. g.fillOval(250,100,30,30);
  88. g.setColor(Color.gray);
  89. g.fillOval(150,200,30,30);
  90. g.fillOval(200,200,30,30);
  91. g.setColor(Color.black);
  92. g.fillOval(250,200,30,30);
  93.  
  94. }
  95. if (pageCt==3)
  96. {
  97. g.setFont(font4);
  98. g.setColor(Color.blue);
  99. g.drawString("How to play!",80,60);
  100. g.setFont(font1);
  101. g.drawString("(Continued)",80,100);
  102. g.drawString("- I will only use each color once.",20,150);
  103. g.drawString("- Each time you guess, the pegs will let you know",20,190);
  104. g.drawString(" how close you are.",20,210);
  105. g.drawString("- Each puzzle will have 3 random colors.",20,250);
  106. g.drawString("- You lowest number of guesses is your goal.",20,290);
  107. }
  108. if (pageCt==4)
  109. {
  110. g.setFont(font2);
  111. g.setColor(Color.blue);
  112. g.drawString("Thank you for",10,50);
  113. g.drawString("for reading the",40,90);
  114. g.drawString("Master Mind",70,130);
  115. g.drawString("tutorial",140,160);
  116. g.setFont(font3);
  117. g.drawString("Written by Max adamski",100,500);
  118. backBtn.setVisible(false);
  119. endBtn.setVisible(false);
  120. nextBtn.setVisible(false);
  121. }
  122. }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement