SlideShare a Scribd company logo
import java.applet.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
public class Main extends Applet implements ActionListener{
Label mainLbl;
Label chooseLbl;
Label resultsLbl;
Label result1;
Label result2;
Label result3;
Button btnRock;
Button btnPaper;
Button btnScissor;
public static final int RESULT_ROCK = 1;
public static final int RESULT_PAPER = 2;
public static final int RESULT_SCISSOR = 3;
int userWin = 0;
int systemWin =0;
int tie;
@Override
public void init() {
// TODO Auto-generated method stub
super.init();
setLayout(null);
//Add UI
mainLbl = new Label("Rock, Papers, Scissors");
mainLbl.setFont(new Font("TimesRoman", Font.BOLD, 25));
mainLbl.setBounds(50, 30, 500, 30);
add(mainLbl);
chooseLbl = new Label("Choose one Button");
chooseLbl.setFont(new Font("TimesRoman", Font.BOLD, 15));
chooseLbl.setBounds(20, 70, 170, 20);
add(chooseLbl);
btnRock = new Button("Rock");
btnRock.setBounds(200, 70, 70, 30);
btnRock.addActionListener(this);
add(btnRock);
btnPaper = new Button("Papers");
btnPaper.setBounds(270, 70, 80, 30);
btnPaper.addActionListener(this);
add(btnPaper);
btnScissor = new Button("Scissors");
btnScissor.setBounds(350, 70, 80, 30);
btnScissor.addActionListener(this);
add(btnScissor);
resultsLbl = new Label("---- Results---");
resultsLbl.setFont(new Font("TimesRoman", Font.BOLD, 15));
resultsLbl.setBounds(100, 110, 170, 20);
add(resultsLbl);
result1 = new Label();
result1.setFont(new Font("TimesRoman", Font.BOLD, 12));
result1.setBounds(20, 140, 300, 20);
add(result1);
result2 = new Label();
result2.setFont(new Font("TimesRoman", Font.BOLD, 12));
result2.setBounds(20, 170, 300, 20);
add(result2);
result3 = new Label();
result3.setFont(new Font("TimesRoman", Font.BOLD, 12));
result3.setBounds(20, 200, 300, 20);
add(result3);
}
public void paint(Graphics g){
this.setSize(500, 330);
g.drawString("Name : You Id : 200  ",40,300);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Random r = new Random();
//get system choice randomly
int syschoice = 0;
syschoice = (int)(Math.random() * ((3 - 1) + 1)) + 1;
//get Answer Randomly
int answer = 0;
answer = (int)(Math.random() * ((3 - 1) + 1)) + 1;
int userChoice = 0;
if(e.getSource() == btnRock){
userChoice = RESULT_ROCK;
}
else if(e.getSource() == btnPaper){
userChoice = RESULT_PAPER;
}
else if(e.getSource() == btnScissor){
userChoice = RESULT_SCISSOR;
}
String Winner = null;
if(userChoice == answer){
Winner = "Winner : You";
userWin++;
}
else if(syschoice == answer){
Winner = "Winner : System";
systemWin++;
}
else{
Winner = "Winner : Tie";
tie++;
}
result2.setText(Winner);
String choice = "You Picked "+choiceFrmInt(userChoice)+"---- System Picked
"+choiceFrmInt(syschoice);
result1.setText(choice);
String result = "You : "+userWin+ " System: "+systemWin + "Tie : "+tie;
result3.setText(result);
}
private String choiceFrmInt(int choice){
String text;
if(choice == RESULT_PAPER){
text = "Paper";
}
else if(choice == RESULT_ROCK){
text = "Rock";
}
else{
text = "Scissor";
}
return text;
}
}
Solution
import java.applet.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
public class Main extends Applet implements ActionListener{
Label mainLbl;
Label chooseLbl;
Label resultsLbl;
Label result1;
Label result2;
Label result3;
Button btnRock;
Button btnPaper;
Button btnScissor;
public static final int RESULT_ROCK = 1;
public static final int RESULT_PAPER = 2;
public static final int RESULT_SCISSOR = 3;
int userWin = 0;
int systemWin =0;
int tie;
@Override
public void init() {
// TODO Auto-generated method stub
super.init();
setLayout(null);
//Add UI
mainLbl = new Label("Rock, Papers, Scissors");
mainLbl.setFont(new Font("TimesRoman", Font.BOLD, 25));
mainLbl.setBounds(50, 30, 500, 30);
add(mainLbl);
chooseLbl = new Label("Choose one Button");
chooseLbl.setFont(new Font("TimesRoman", Font.BOLD, 15));
chooseLbl.setBounds(20, 70, 170, 20);
add(chooseLbl);
btnRock = new Button("Rock");
btnRock.setBounds(200, 70, 70, 30);
btnRock.addActionListener(this);
add(btnRock);
btnPaper = new Button("Papers");
btnPaper.setBounds(270, 70, 80, 30);
btnPaper.addActionListener(this);
add(btnPaper);
btnScissor = new Button("Scissors");
btnScissor.setBounds(350, 70, 80, 30);
btnScissor.addActionListener(this);
add(btnScissor);
resultsLbl = new Label("---- Results---");
resultsLbl.setFont(new Font("TimesRoman", Font.BOLD, 15));
resultsLbl.setBounds(100, 110, 170, 20);
add(resultsLbl);
result1 = new Label();
result1.setFont(new Font("TimesRoman", Font.BOLD, 12));
result1.setBounds(20, 140, 300, 20);
add(result1);
result2 = new Label();
result2.setFont(new Font("TimesRoman", Font.BOLD, 12));
result2.setBounds(20, 170, 300, 20);
add(result2);
result3 = new Label();
result3.setFont(new Font("TimesRoman", Font.BOLD, 12));
result3.setBounds(20, 200, 300, 20);
add(result3);
}
public void paint(Graphics g){
this.setSize(500, 330);
g.drawString("Name : You Id : 200  ",40,300);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Random r = new Random();
//get system choice randomly
int syschoice = 0;
syschoice = (int)(Math.random() * ((3 - 1) + 1)) + 1;
//get Answer Randomly
int answer = 0;
answer = (int)(Math.random() * ((3 - 1) + 1)) + 1;
int userChoice = 0;
if(e.getSource() == btnRock){
userChoice = RESULT_ROCK;
}
else if(e.getSource() == btnPaper){
userChoice = RESULT_PAPER;
}
else if(e.getSource() == btnScissor){
userChoice = RESULT_SCISSOR;
}
String Winner = null;
if(userChoice == answer){
Winner = "Winner : You";
userWin++;
}
else if(syschoice == answer){
Winner = "Winner : System";
systemWin++;
}
else{
Winner = "Winner : Tie";
tie++;
}
result2.setText(Winner);
String choice = "You Picked "+choiceFrmInt(userChoice)+"---- System Picked
"+choiceFrmInt(syschoice);
result1.setText(choice);
String result = "You : "+userWin+ " System: "+systemWin + "Tie : "+tie;
result3.setText(result);
}
private String choiceFrmInt(int choice){
String text;
if(choice == RESULT_PAPER){
text = "Paper";
}
else if(choice == RESULT_ROCK){
text = "Rock";
}
else{
text = "Scissor";
}
return text;
}
}

More Related Content

Similar to import java.applet.; import java.awt.; import java.awt.event.A.pdf

1st program
1st program1st program
1st program
Jawad Shinwari
 
Java File
Java FileJava File
Java File
Archita Misra
 
GeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good TestsGeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good Tests
Tomek Kaczanowski
 
Algoritmos sujei
Algoritmos sujeiAlgoritmos sujei
Algoritmos sujei
gersonjack
 
step by step to write a gnome-shell extension
step by step to write a gnome-shell extension step by step to write a gnome-shell extension
step by step to write a gnome-shell extension Yuren Ju
 
Signalsで Event処理を簡単に
Signalsで Event処理を簡単にSignalsで Event処理を簡単に
Signalsで Event処理を簡単に
Hiroaki Okubo
 
Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3martha leon
 
Lab1.javaimport java.util.Scanner;package public class Lab1 .pdf
Lab1.javaimport java.util.Scanner;package public class Lab1 .pdfLab1.javaimport java.util.Scanner;package public class Lab1 .pdf
Lab1.javaimport java.util.Scanner;package public class Lab1 .pdf
anupamselection
 
How do I make my JTable non editableimport java.awt.; import j.pdf
How do I make my JTable non editableimport java.awt.; import j.pdfHow do I make my JTable non editableimport java.awt.; import j.pdf
How do I make my JTable non editableimport java.awt.; import j.pdf
forwardcom41
 
Program klik sederhana
Program klik sederhanaProgram klik sederhana
Program klik sederhana
Henfry Kai
 
Nouveau document texte-_-_
Nouveau document texte-_-_Nouveau document texte-_-_
Nouveau document texte-_-_
Mohamed Mlika
 
import java.util.Arrays;import components.simplereader.SimpleReade.pdf
import java.util.Arrays;import components.simplereader.SimpleReade.pdfimport java.util.Arrays;import components.simplereader.SimpleReade.pdf
import java.util.Arrays;import components.simplereader.SimpleReade.pdf
sudhinjv
 
Androidaop 170105090257
Androidaop 170105090257Androidaop 170105090257
Androidaop 170105090257
newegg
 
Manual tecnico
Manual tecnicoManual tecnico
Manual tecnico481200601
 
안드로이드 세미나 2
안드로이드 세미나 2안드로이드 세미나 2
안드로이드 세미나 2
Chul Ju Hong
 
Java 8 lambda expressions
Java 8 lambda expressionsJava 8 lambda expressions
Java 8 lambda expressions
Logan Chien
 
Manual tecnico
Manual tecnicoManual tecnico
Manual tecnico481200601
 

Similar to import java.applet.; import java.awt.; import java.awt.event.A.pdf (20)

1st program
1st program1st program
1st program
 
Java File
Java FileJava File
Java File
 
New text document
New text documentNew text document
New text document
 
Lecture9 oopj
Lecture9 oopjLecture9 oopj
Lecture9 oopj
 
GeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good TestsGeeCON 2012 Bad Tests, Good Tests
GeeCON 2012 Bad Tests, Good Tests
 
Algoritmos sujei
Algoritmos sujeiAlgoritmos sujei
Algoritmos sujei
 
step by step to write a gnome-shell extension
step by step to write a gnome-shell extension step by step to write a gnome-shell extension
step by step to write a gnome-shell extension
 
2011 07-hiyoko
2011 07-hiyoko2011 07-hiyoko
2011 07-hiyoko
 
Signalsで Event処理を簡単に
Signalsで Event処理を簡単にSignalsで Event処理を簡単に
Signalsで Event処理を簡単に
 
Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3
 
Lab1.javaimport java.util.Scanner;package public class Lab1 .pdf
Lab1.javaimport java.util.Scanner;package public class Lab1 .pdfLab1.javaimport java.util.Scanner;package public class Lab1 .pdf
Lab1.javaimport java.util.Scanner;package public class Lab1 .pdf
 
How do I make my JTable non editableimport java.awt.; import j.pdf
How do I make my JTable non editableimport java.awt.; import j.pdfHow do I make my JTable non editableimport java.awt.; import j.pdf
How do I make my JTable non editableimport java.awt.; import j.pdf
 
Program klik sederhana
Program klik sederhanaProgram klik sederhana
Program klik sederhana
 
Nouveau document texte-_-_
Nouveau document texte-_-_Nouveau document texte-_-_
Nouveau document texte-_-_
 
import java.util.Arrays;import components.simplereader.SimpleReade.pdf
import java.util.Arrays;import components.simplereader.SimpleReade.pdfimport java.util.Arrays;import components.simplereader.SimpleReade.pdf
import java.util.Arrays;import components.simplereader.SimpleReade.pdf
 
Androidaop 170105090257
Androidaop 170105090257Androidaop 170105090257
Androidaop 170105090257
 
Manual tecnico
Manual tecnicoManual tecnico
Manual tecnico
 
안드로이드 세미나 2
안드로이드 세미나 2안드로이드 세미나 2
안드로이드 세미나 2
 
Java 8 lambda expressions
Java 8 lambda expressionsJava 8 lambda expressions
Java 8 lambda expressions
 
Manual tecnico
Manual tecnicoManual tecnico
Manual tecnico
 

More from apnafreez

Cu(H2O)42+(aq) + 4CN-(aq) = Cu(CN)42-(aq) +4 H2O(l)Cu+2 is a Lew.pdf
Cu(H2O)42+(aq) + 4CN-(aq) = Cu(CN)42-(aq) +4 H2O(l)Cu+2 is a Lew.pdfCu(H2O)42+(aq) + 4CN-(aq) = Cu(CN)42-(aq) +4 H2O(l)Cu+2 is a Lew.pdf
Cu(H2O)42+(aq) + 4CN-(aq) = Cu(CN)42-(aq) +4 H2O(l)Cu+2 is a Lew.pdf
apnafreez
 
C) CS2 for sureA, B, D and E are all ionic compoundsSolution.pdf
C) CS2 for sureA, B, D and E are all ionic compoundsSolution.pdfC) CS2 for sureA, B, D and E are all ionic compoundsSolution.pdf
C) CS2 for sureA, B, D and E are all ionic compoundsSolution.pdf
apnafreez
 
Before getting public issues he should consider are 1. Increase i.pdf
Before getting public issues he should consider are 1. Increase i.pdfBefore getting public issues he should consider are 1. Increase i.pdf
Before getting public issues he should consider are 1. Increase i.pdf
apnafreez
 
Assets=Liabilities+Stockholders EquityCash given $1000 on the sa.pdf
Assets=Liabilities+Stockholders EquityCash given $1000 on the sa.pdfAssets=Liabilities+Stockholders EquityCash given $1000 on the sa.pdf
Assets=Liabilities+Stockholders EquityCash given $1000 on the sa.pdf
apnafreez
 
1)Interest per year 8106= 135Simple interest = Amount RateTime.pdf
1)Interest per year 8106= 135Simple interest = Amount  RateTime.pdf1)Interest per year 8106= 135Simple interest = Amount  RateTime.pdf
1)Interest per year 8106= 135Simple interest = Amount RateTime.pdf
apnafreez
 
AnswerAnswer1. The body of a fungus is in the form of solid sh.pdf
AnswerAnswer1. The body of a fungus is in the form of solid sh.pdfAnswerAnswer1. The body of a fungus is in the form of solid sh.pdf
AnswerAnswer1. The body of a fungus is in the form of solid sh.pdf
apnafreez
 
A. This constitutes part of a gene that encodes information for RNA .pdf
A. This constitutes part of a gene that encodes information for RNA .pdfA. This constitutes part of a gene that encodes information for RNA .pdf
A. This constitutes part of a gene that encodes information for RNA .pdf
apnafreez
 
A. ANSAutosomal dominant (a trait could passed down from previous.pdf
A. ANSAutosomal dominant (a trait could passed down from previous.pdfA. ANSAutosomal dominant (a trait could passed down from previous.pdf
A. ANSAutosomal dominant (a trait could passed down from previous.pdf
apnafreez
 
888678123317368915236 #include stdio.h #include stdlib.h.pdf
888678123317368915236 #include stdio.h #include stdlib.h.pdf888678123317368915236 #include stdio.h #include stdlib.h.pdf
888678123317368915236 #include stdio.h #include stdlib.h.pdf
apnafreez
 
18) One device is attached to a physical interface    The switch c.pdf
18) One device is attached to a physical interface    The switch c.pdf18) One device is attached to a physical interface    The switch c.pdf
18) One device is attached to a physical interface    The switch c.pdf
apnafreez
 
1.Joseph could not restrain himself before all those who stood by hi.pdf
1.Joseph could not restrain himself before all those who stood by hi.pdf1.Joseph could not restrain himself before all those who stood by hi.pdf
1.Joseph could not restrain himself before all those who stood by hi.pdf
apnafreez
 
(a) Total amount of I2 = 501000 x 0.010 = 0.0005 mol = 0.5 mmolLe.pdf
(a) Total amount of I2 = 501000 x 0.010 = 0.0005 mol = 0.5 mmolLe.pdf(a) Total amount of I2 = 501000 x 0.010 = 0.0005 mol = 0.5 mmolLe.pdf
(a) Total amount of I2 = 501000 x 0.010 = 0.0005 mol = 0.5 mmolLe.pdf
apnafreez
 
Nursing is a healthcare profession in which they serve the patients .pdf
  Nursing is a healthcare profession in which they serve the patients .pdf  Nursing is a healthcare profession in which they serve the patients .pdf
Nursing is a healthcare profession in which they serve the patients .pdf
apnafreez
 
yes.because the deposted money can be multiply with 10 and it beco.pdf
yes.because the deposted money can be multiply with 10 and it beco.pdfyes.because the deposted money can be multiply with 10 and it beco.pdf
yes.because the deposted money can be multiply with 10 and it beco.pdf
apnafreez
 
When the substituent groups are oriented in the s.pdf
                     When the substituent groups are oriented in the s.pdf                     When the substituent groups are oriented in the s.pdf
When the substituent groups are oriented in the s.pdf
apnafreez
 
using System;public category take a look at one.00m; Console.W.pdf
using System;public category take a look at one.00m; Console.W.pdfusing System;public category take a look at one.00m; Console.W.pdf
using System;public category take a look at one.00m; Console.W.pdf
apnafreez
 
Tunnel through the IPv4--Internet traffic is expected to be carr.pdf
Tunnel through the IPv4--Internet traffic is expected to be carr.pdfTunnel through the IPv4--Internet traffic is expected to be carr.pdf
Tunnel through the IPv4--Internet traffic is expected to be carr.pdf
apnafreez
 
The sum is 250.SolutionThe sum is 250..pdf
The sum is 250.SolutionThe sum is 250..pdfThe sum is 250.SolutionThe sum is 250..pdf
The sum is 250.SolutionThe sum is 250..pdf
apnafreez
 
The  key activity areas for securities firms are i. Investing Se.pdf
The  key activity areas for securities firms are i. Investing Se.pdfThe  key activity areas for securities firms are i. Investing Se.pdf
The  key activity areas for securities firms are i. Investing Se.pdf
apnafreez
 
The finger like projections of intestine known as villi increases su.pdf
The finger like projections of intestine known as villi increases su.pdfThe finger like projections of intestine known as villi increases su.pdf
The finger like projections of intestine known as villi increases su.pdf
apnafreez
 

More from apnafreez (20)

Cu(H2O)42+(aq) + 4CN-(aq) = Cu(CN)42-(aq) +4 H2O(l)Cu+2 is a Lew.pdf
Cu(H2O)42+(aq) + 4CN-(aq) = Cu(CN)42-(aq) +4 H2O(l)Cu+2 is a Lew.pdfCu(H2O)42+(aq) + 4CN-(aq) = Cu(CN)42-(aq) +4 H2O(l)Cu+2 is a Lew.pdf
Cu(H2O)42+(aq) + 4CN-(aq) = Cu(CN)42-(aq) +4 H2O(l)Cu+2 is a Lew.pdf
 
C) CS2 for sureA, B, D and E are all ionic compoundsSolution.pdf
C) CS2 for sureA, B, D and E are all ionic compoundsSolution.pdfC) CS2 for sureA, B, D and E are all ionic compoundsSolution.pdf
C) CS2 for sureA, B, D and E are all ionic compoundsSolution.pdf
 
Before getting public issues he should consider are 1. Increase i.pdf
Before getting public issues he should consider are 1. Increase i.pdfBefore getting public issues he should consider are 1. Increase i.pdf
Before getting public issues he should consider are 1. Increase i.pdf
 
Assets=Liabilities+Stockholders EquityCash given $1000 on the sa.pdf
Assets=Liabilities+Stockholders EquityCash given $1000 on the sa.pdfAssets=Liabilities+Stockholders EquityCash given $1000 on the sa.pdf
Assets=Liabilities+Stockholders EquityCash given $1000 on the sa.pdf
 
1)Interest per year 8106= 135Simple interest = Amount RateTime.pdf
1)Interest per year 8106= 135Simple interest = Amount  RateTime.pdf1)Interest per year 8106= 135Simple interest = Amount  RateTime.pdf
1)Interest per year 8106= 135Simple interest = Amount RateTime.pdf
 
AnswerAnswer1. The body of a fungus is in the form of solid sh.pdf
AnswerAnswer1. The body of a fungus is in the form of solid sh.pdfAnswerAnswer1. The body of a fungus is in the form of solid sh.pdf
AnswerAnswer1. The body of a fungus is in the form of solid sh.pdf
 
A. This constitutes part of a gene that encodes information for RNA .pdf
A. This constitutes part of a gene that encodes information for RNA .pdfA. This constitutes part of a gene that encodes information for RNA .pdf
A. This constitutes part of a gene that encodes information for RNA .pdf
 
A. ANSAutosomal dominant (a trait could passed down from previous.pdf
A. ANSAutosomal dominant (a trait could passed down from previous.pdfA. ANSAutosomal dominant (a trait could passed down from previous.pdf
A. ANSAutosomal dominant (a trait could passed down from previous.pdf
 
888678123317368915236 #include stdio.h #include stdlib.h.pdf
888678123317368915236 #include stdio.h #include stdlib.h.pdf888678123317368915236 #include stdio.h #include stdlib.h.pdf
888678123317368915236 #include stdio.h #include stdlib.h.pdf
 
18) One device is attached to a physical interface    The switch c.pdf
18) One device is attached to a physical interface    The switch c.pdf18) One device is attached to a physical interface    The switch c.pdf
18) One device is attached to a physical interface    The switch c.pdf
 
1.Joseph could not restrain himself before all those who stood by hi.pdf
1.Joseph could not restrain himself before all those who stood by hi.pdf1.Joseph could not restrain himself before all those who stood by hi.pdf
1.Joseph could not restrain himself before all those who stood by hi.pdf
 
(a) Total amount of I2 = 501000 x 0.010 = 0.0005 mol = 0.5 mmolLe.pdf
(a) Total amount of I2 = 501000 x 0.010 = 0.0005 mol = 0.5 mmolLe.pdf(a) Total amount of I2 = 501000 x 0.010 = 0.0005 mol = 0.5 mmolLe.pdf
(a) Total amount of I2 = 501000 x 0.010 = 0.0005 mol = 0.5 mmolLe.pdf
 
Nursing is a healthcare profession in which they serve the patients .pdf
  Nursing is a healthcare profession in which they serve the patients .pdf  Nursing is a healthcare profession in which they serve the patients .pdf
Nursing is a healthcare profession in which they serve the patients .pdf
 
yes.because the deposted money can be multiply with 10 and it beco.pdf
yes.because the deposted money can be multiply with 10 and it beco.pdfyes.because the deposted money can be multiply with 10 and it beco.pdf
yes.because the deposted money can be multiply with 10 and it beco.pdf
 
When the substituent groups are oriented in the s.pdf
                     When the substituent groups are oriented in the s.pdf                     When the substituent groups are oriented in the s.pdf
When the substituent groups are oriented in the s.pdf
 
using System;public category take a look at one.00m; Console.W.pdf
using System;public category take a look at one.00m; Console.W.pdfusing System;public category take a look at one.00m; Console.W.pdf
using System;public category take a look at one.00m; Console.W.pdf
 
Tunnel through the IPv4--Internet traffic is expected to be carr.pdf
Tunnel through the IPv4--Internet traffic is expected to be carr.pdfTunnel through the IPv4--Internet traffic is expected to be carr.pdf
Tunnel through the IPv4--Internet traffic is expected to be carr.pdf
 
The sum is 250.SolutionThe sum is 250..pdf
The sum is 250.SolutionThe sum is 250..pdfThe sum is 250.SolutionThe sum is 250..pdf
The sum is 250.SolutionThe sum is 250..pdf
 
The  key activity areas for securities firms are i. Investing Se.pdf
The  key activity areas for securities firms are i. Investing Se.pdfThe  key activity areas for securities firms are i. Investing Se.pdf
The  key activity areas for securities firms are i. Investing Se.pdf
 
The finger like projections of intestine known as villi increases su.pdf
The finger like projections of intestine known as villi increases su.pdfThe finger like projections of intestine known as villi increases su.pdf
The finger like projections of intestine known as villi increases su.pdf
 

Recently uploaded

Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 

Recently uploaded (20)

Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 

import java.applet.; import java.awt.; import java.awt.event.A.pdf

  • 1. import java.applet.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Random; public class Main extends Applet implements ActionListener{ Label mainLbl; Label chooseLbl; Label resultsLbl; Label result1; Label result2; Label result3; Button btnRock; Button btnPaper; Button btnScissor; public static final int RESULT_ROCK = 1; public static final int RESULT_PAPER = 2; public static final int RESULT_SCISSOR = 3; int userWin = 0; int systemWin =0; int tie; @Override public void init() { // TODO Auto-generated method stub super.init(); setLayout(null); //Add UI mainLbl = new Label("Rock, Papers, Scissors"); mainLbl.setFont(new Font("TimesRoman", Font.BOLD, 25)); mainLbl.setBounds(50, 30, 500, 30); add(mainLbl); chooseLbl = new Label("Choose one Button"); chooseLbl.setFont(new Font("TimesRoman", Font.BOLD, 15)); chooseLbl.setBounds(20, 70, 170, 20);
  • 2. add(chooseLbl); btnRock = new Button("Rock"); btnRock.setBounds(200, 70, 70, 30); btnRock.addActionListener(this); add(btnRock); btnPaper = new Button("Papers"); btnPaper.setBounds(270, 70, 80, 30); btnPaper.addActionListener(this); add(btnPaper); btnScissor = new Button("Scissors"); btnScissor.setBounds(350, 70, 80, 30); btnScissor.addActionListener(this); add(btnScissor); resultsLbl = new Label("---- Results---"); resultsLbl.setFont(new Font("TimesRoman", Font.BOLD, 15)); resultsLbl.setBounds(100, 110, 170, 20); add(resultsLbl); result1 = new Label(); result1.setFont(new Font("TimesRoman", Font.BOLD, 12)); result1.setBounds(20, 140, 300, 20); add(result1); result2 = new Label(); result2.setFont(new Font("TimesRoman", Font.BOLD, 12)); result2.setBounds(20, 170, 300, 20); add(result2); result3 = new Label(); result3.setFont(new Font("TimesRoman", Font.BOLD, 12)); result3.setBounds(20, 200, 300, 20); add(result3);
  • 3. } public void paint(Graphics g){ this.setSize(500, 330); g.drawString("Name : You Id : 200 ",40,300); } @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub Random r = new Random(); //get system choice randomly int syschoice = 0; syschoice = (int)(Math.random() * ((3 - 1) + 1)) + 1; //get Answer Randomly int answer = 0; answer = (int)(Math.random() * ((3 - 1) + 1)) + 1; int userChoice = 0; if(e.getSource() == btnRock){ userChoice = RESULT_ROCK; } else if(e.getSource() == btnPaper){ userChoice = RESULT_PAPER; } else if(e.getSource() == btnScissor){ userChoice = RESULT_SCISSOR; } String Winner = null; if(userChoice == answer){ Winner = "Winner : You"; userWin++; } else if(syschoice == answer){ Winner = "Winner : System"; systemWin++;
  • 4. } else{ Winner = "Winner : Tie"; tie++; } result2.setText(Winner); String choice = "You Picked "+choiceFrmInt(userChoice)+"---- System Picked "+choiceFrmInt(syschoice); result1.setText(choice); String result = "You : "+userWin+ " System: "+systemWin + "Tie : "+tie; result3.setText(result); } private String choiceFrmInt(int choice){ String text; if(choice == RESULT_PAPER){ text = "Paper"; } else if(choice == RESULT_ROCK){ text = "Rock"; } else{ text = "Scissor"; } return text; } } Solution
  • 5. import java.applet.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Random; public class Main extends Applet implements ActionListener{ Label mainLbl; Label chooseLbl; Label resultsLbl; Label result1; Label result2; Label result3; Button btnRock; Button btnPaper; Button btnScissor; public static final int RESULT_ROCK = 1; public static final int RESULT_PAPER = 2; public static final int RESULT_SCISSOR = 3; int userWin = 0; int systemWin =0; int tie; @Override public void init() { // TODO Auto-generated method stub super.init(); setLayout(null); //Add UI mainLbl = new Label("Rock, Papers, Scissors"); mainLbl.setFont(new Font("TimesRoman", Font.BOLD, 25)); mainLbl.setBounds(50, 30, 500, 30); add(mainLbl); chooseLbl = new Label("Choose one Button"); chooseLbl.setFont(new Font("TimesRoman", Font.BOLD, 15)); chooseLbl.setBounds(20, 70, 170, 20);
  • 6. add(chooseLbl); btnRock = new Button("Rock"); btnRock.setBounds(200, 70, 70, 30); btnRock.addActionListener(this); add(btnRock); btnPaper = new Button("Papers"); btnPaper.setBounds(270, 70, 80, 30); btnPaper.addActionListener(this); add(btnPaper); btnScissor = new Button("Scissors"); btnScissor.setBounds(350, 70, 80, 30); btnScissor.addActionListener(this); add(btnScissor); resultsLbl = new Label("---- Results---"); resultsLbl.setFont(new Font("TimesRoman", Font.BOLD, 15)); resultsLbl.setBounds(100, 110, 170, 20); add(resultsLbl); result1 = new Label(); result1.setFont(new Font("TimesRoman", Font.BOLD, 12)); result1.setBounds(20, 140, 300, 20); add(result1); result2 = new Label(); result2.setFont(new Font("TimesRoman", Font.BOLD, 12)); result2.setBounds(20, 170, 300, 20); add(result2); result3 = new Label(); result3.setFont(new Font("TimesRoman", Font.BOLD, 12)); result3.setBounds(20, 200, 300, 20); add(result3);
  • 7. } public void paint(Graphics g){ this.setSize(500, 330); g.drawString("Name : You Id : 200 ",40,300); } @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub Random r = new Random(); //get system choice randomly int syschoice = 0; syschoice = (int)(Math.random() * ((3 - 1) + 1)) + 1; //get Answer Randomly int answer = 0; answer = (int)(Math.random() * ((3 - 1) + 1)) + 1; int userChoice = 0; if(e.getSource() == btnRock){ userChoice = RESULT_ROCK; } else if(e.getSource() == btnPaper){ userChoice = RESULT_PAPER; } else if(e.getSource() == btnScissor){ userChoice = RESULT_SCISSOR; } String Winner = null; if(userChoice == answer){ Winner = "Winner : You"; userWin++; } else if(syschoice == answer){ Winner = "Winner : System"; systemWin++;
  • 8. } else{ Winner = "Winner : Tie"; tie++; } result2.setText(Winner); String choice = "You Picked "+choiceFrmInt(userChoice)+"---- System Picked "+choiceFrmInt(syschoice); result1.setText(choice); String result = "You : "+userWin+ " System: "+systemWin + "Tie : "+tie; result3.setText(result); } private String choiceFrmInt(int choice){ String text; if(choice == RESULT_PAPER){ text = "Paper"; } else if(choice == RESULT_ROCK){ text = "Rock"; } else{ text = "Scissor"; } return text; } }