Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import javax.swing.JOptionPane;
- public class Setup
- {
- private int pile;
- private int comp;
- private String pname;
- private String diff;
- Random randNum = new Random();
- public Setup()
- {
- pile = 0;
- }
- public void setName()
- {
- String name = JOptionPane.showInputDialog("What is your name?");
- pname = name;
- }
- public void setPileSize()
- {
- String input = JOptionPane.showInputDialog("How big of a pile? From 10-100");
- int amt = Integer.parseInt(input);
- while (amt < 10 || amt > 100)
- {
- input = JOptionPane.showInputDialog("How big of a pile? From 10-100");
- amt = Integer.parseInt(input);
- }
- pile = amt;
- }
- public void ranPileSize()
- {
- int f = 1+randNum.nextInt(100);
- while (f<10)
- f = 1+randNum.nextInt(100);
- pile = f;
- }
- public void setComp()
- {
- String input = JOptionPane.showInputDialog("Dumb or Smart computer? Dumb = 0, Smart = 1");
- int amt = Integer.parseInt(input);
- do
- {
- if (input.equals("0"))
- diff = "Dumb";
- else if (input.equals("1"))
- diff = "Smart";
- else
- {
- input = JOptionPane.showInputDialog("Dumb or Smart ccomputer? Dumb = 0, Smart = 1");
- amt = Integer.parseInt(input);
- }
- } while (amt < 0 || amt > 1);
- }
- public int getPile()
- {
- return pile;
- }
- public String getName()
- {
- return pname;
- }
- public String getDiff()
- {
- return diff;
- }
- public int runPile()
- {
- setName();
- setComp();
- String input = JOptionPane.showInputDialog("Random size or Select size? 0 = Select, 1 = Random");
- int amt = Integer.parseInt(input);
- if (amt == 0)
- setPileSize();
- else if (amt == 1)
- ranPileSize();
- while (amt < 0 || amt > 1)
- {
- input = JOptionPane.showInputDialog("Random size or Select size? 0 = Select, 1 = Random");
- amt = Integer.parseInt(input);
- }
- System.out.println("Player name: "+ getName() + "\nPile Size: "+ getPile() + "\nDifficulty: " + getDiff());
- System.exit(0);
- return pile;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement