Rock, Paper, Scissors query?

Hi there, I have a "limiting" question I'm hoping someone can help me out with.
I work for a hospital on the employee's database. I'm trying to update a column in the employee demographic table called "workgroup". It's never been used before so currently the column sits empty.
I need to place one of 3 different codes in that column based on the level of patient contact the employee has. D = Direct contact, I = Indirect contact and N = No contact.
I will need to base this off of another table called Exposures. It's a table that tracks the level of exposure the employee is subjected to. So ER nurses would be Level 1, but the cleaning crew are Level 3.
Here's my problem, unfortunately due to poor past practices, many people are in more than one Level. For example, most nurses are in both Level 1 and Level 2. The reason for this... I have no idea.
So my question is, how if say Sara Johnson was in Level 1 and Level 2, would I place a "D" in her workgroup column and that's it. I've built a script with a CASE statement but that doesn't give me what I want. I gives her both a "D" and an "I". But the "D" is more important - it trumps the "I". Get it? Basically it's like rock paper scissors.

MIN worked great!! Thanks a lot!! I think this just saved us a lot of manual excel work.
Here's the script: (sorry about the formatting)
SELECT     E.ID, E.LNAME, E.FNAME, NVL(E.MI,' ') MI, E.BDATE,
     MIN(B.CODE) CODE, MIN(B.WKGP) WKGP,
     L.DESCR
FROM     EMPLOYEE E, LOC L,     (SELECT     EMPLOYEE EE, EXPOSURE CODE,
                         CASE      WHEN EXPOSURE = 'Level 1' THEN 'D'
                              WHEN FLDEXPOSURE = 'Level 2' THEN 'I'
                              WHEN FLDEXPOSURE = 'Level 3' THEN 'N'
                              ELSE     ' '
                         END WKGP
                    FROM     EXPHIST
                    WHERE     FLDEXPOSURE IN ('Level 1','Level 2','Level 3')) B
WHERE     E.LOC = L.CODE          AND
     L.CODE = 'South'      AND
     E.STATUS IN     (SELECT CODE
               FROM     EMPSTATS
               WHERE     ACTIVE <> 'n')     AND
     E.REC_NUM = B.EE
GROUP BY E.ID, E.LNAME, E.FNAME, E.MI, E.BDATE,
     L.DESCR
ORDER BY E.LNAME, E.FNAME

Similar Messages

  • Help with getting Images to show in a Rock, Paper, Scissors game

    Hi
    I am working on this Rock, paper, scissors java game and the program works, but I can not figure out how to get the images to load onto the program. So my question is how do I get the images to load up with the program? I am using JCreator for this project. I have created the Basic Java Application project, and then added in the 3 .java files that I need to run the program, but I just can not figure out how or where I need to upload the files. The game works without the images, but I would really like them to show up.
    This is the .java file that calls up the images:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class pss extends JPanel implements ActionListener, ItemListener
    private final Color clrBackground = new Color(163,243,255);
    private final Color clrForeground = new Color(0,0,0);
    private JComboBox cboxWeapon;
    private JTextField txtCPUWeapon, txtWins, txtLoses, txtDraws;
    private JLabel lblPlayerWeapon, lblCPUWeapon, lblWins, lblLoses, lblDraws, lblStatus, lblPlayerWeaponIcon, lblCPUWeaponIcon;
    private JButton cmdPlay, cmdReset;
    private ImageIcon[] imgWeapon;
    private JPanel panRoot, panPlayerArea, panPlayerWeapon, panCPUArea, panCPUWeapon, panStatusArea, panGo, panCounters, panWins, panLoses, panDraws;
    private pssEngine engine = new pssEngine();
    private objCreateAppletImage createImage = new objCreateAppletImage();
    private boolean errorWithImages = false;
    public static void main(String[] args) //With applications, you have to specify a main method (not with applets)
    JFrame.setDefaultLookAndFeelDecorated(true); //Make it look nice
    JFrame frame = new JFrame("Paper Stone Scissors"); //Title
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setResizable(false); //Stops the user resizing the window
    JComponent paneMain = new pss();
    paneMain.setOpaque(true);
    paneMain.setPreferredSize(new Dimension(420,350));
    frame.setContentPane(paneMain);
    frame.pack();
    frame.setVisible(true);
    public pss ()
    cboxWeapon = new JComboBox(engine.getWeapon());
    cboxWeapon.addItemListener(this);
    txtCPUWeapon = new JTextField(engine.getStrCPUWeapon(), 5);
    txtWins = new JTextField("0", 5);
    txtLoses = new JTextField("0", 5);
    txtDraws = new JTextField("0", 5);
    txtCPUWeapon.setEditable(false);
    txtWins.setEditable(false);
    txtLoses.setEditable(false);
    txtDraws.setEditable(false);
    lblPlayerWeapon = new JLabel("Choose your weapon", JLabel.CENTER);
    lblCPUWeapon = new JLabel("The CPU's weapon", JLabel.CENTER);
    lblWins = new JLabel("Amount of wins:", JLabel.RIGHT);
    lblLoses = new JLabel("Amount of loses:", JLabel.RIGHT);
    lblDraws = new JLabel("Amount of Drawss:", JLabel.RIGHT);
    lblStatus = new JLabel("", JLabel.CENTER);
    lblPlayerWeaponIcon = new JLabel("", JLabel.CENTER);
    lblCPUWeaponIcon = new JLabel("", JLabel.CENTER);
    lblPlayerWeaponIcon.setPreferredSize(new Dimension(150,150));
    lblCPUWeaponIcon.setPreferredSize(new Dimension(150,150));
    cmdPlay = new JButton("Go!");
    cmdReset = new JButton("Restart");
    cmdPlay.addActionListener(this);
    cmdReset.addActionListener(this);
    try
    imgWeapon = new ImageIcon[3];
    for (int i = 0; i < 3; i++)
    imgWeapon[i] = createImage.getImageIcon(this, ".src/images/" + engine.getWeapon(i) + ".gif", "Icon for " + engine.getWeapon(i), 13000);
    lblPlayerWeaponIcon.setIcon(imgWeapon[0]);
    lblCPUWeaponIcon.setIcon(imgWeapon[0]);
    catch (Exception ex) //The game works without the images, so carry on
    errorWithImages = true;
    setLayout(new BorderLayout());
    panRoot = new JPanel(new BorderLayout());
    panPlayerArea = new JPanel(new BorderLayout());
    panPlayerWeapon = new JPanel(new BorderLayout());
    panCPUArea = new JPanel(new BorderLayout());
    panCPUWeapon = new JPanel(new BorderLayout());
    panStatusArea = new JPanel(new BorderLayout());
    panGo = new JPanel();
    panCounters = new JPanel(new GridLayout(3,1,2,2));
    panWins = new JPanel();
    panLoses = new JPanel();
    panDraws = new JPanel();
    add(panRoot, BorderLayout.CENTER);
    panRoot.add(panPlayerArea, BorderLayout.WEST);
    panPlayerArea.add(panPlayerWeapon, BorderLayout.NORTH);
    panPlayerWeapon.add(lblPlayerWeapon, BorderLayout.NORTH);
    panPlayerWeapon.add(cboxWeapon, BorderLayout.SOUTH);
    panPlayerArea.add(lblPlayerWeaponIcon, BorderLayout.SOUTH);
    panRoot.add(panCPUArea, BorderLayout.EAST);
    panCPUArea.add(panCPUWeapon, BorderLayout.NORTH);
    panCPUWeapon.add(lblCPUWeapon, BorderLayout.NORTH);
    panCPUWeapon.add(txtCPUWeapon, BorderLayout.SOUTH);
    panCPUArea.add(lblCPUWeaponIcon, BorderLayout.SOUTH);
    panRoot.add(panStatusArea, BorderLayout.SOUTH);
    panStatusArea.add(panGo, BorderLayout.NORTH);
    panGo.add(cmdPlay);
    panGo.add(cmdReset);
    panGo.add(lblStatus);
    panStatusArea.add(panCounters, BorderLayout.SOUTH);
    panCounters.add(panWins);
    panWins.add(lblWins);
    panWins.add(txtWins);
    panCounters.add(panLoses);
    panLoses.add(lblLoses);
    panLoses.add(txtLoses);
    panCounters.add(panDraws);
    panDraws.add(lblDraws);
    panDraws.add(txtDraws);
    panRoot.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    setBackground(clrBackground);
    panRoot.setBackground(clrBackground);
    panPlayerArea.setBackground(clrBackground);
    panPlayerWeapon.setBackground(clrBackground);
    panCPUArea.setBackground(clrBackground);
    panCPUWeapon.setBackground(clrBackground);
    panStatusArea.setBackground(clrBackground);
    panGo.setBackground(clrBackground);
    panCounters.setBackground(clrBackground);
    panWins.setBackground(clrBackground);
    panLoses.setBackground(clrBackground);
    panDraws.setBackground(clrBackground);
    lblPlayerWeapon.setForeground(clrForeground);
    lblCPUWeapon.setForeground(clrForeground);
    lblWins.setForeground(clrForeground);
    lblLoses.setForeground(clrForeground);
    lblDraws.setForeground(clrForeground);
    txtWins.setForeground(clrForeground);
    txtLoses.setForeground(clrForeground);
    txtDraws.setForeground(clrForeground);
    txtCPUWeapon.setForeground(clrForeground);
    public void reset ()
    cboxWeapon.setSelectedIndex(0);
    lblStatus.setText("");
    engine.reset();
    public void actionPerformed (ActionEvent e)
    if (e.getSource() == cmdReset)
    reset();
    else
    lblStatus.setText(engine.play(cboxWeapon.getSelectedIndex()));
    txtCPUWeapon.setText(engine.getStrCPUWeapon());
    txtWins.setText(Integer.toString(engine.getWins()));
    txtLoses.setText(Integer.toString(engine.getLoses()));
    txtDraws.setText(Integer.toString(engine.getDraws()));
    if (!errorWithImages)
    lblCPUWeaponIcon.setIcon(imgWeapon[engine.getCPUWeapon()]);
    public void itemStateChanged (ItemEvent e)
    if (!errorWithImages)
    lblPlayerWeaponIcon.setIcon(imgWeapon[cboxWeapon.getSelectedIndex()]);
    }Here is the other .java file that calls on the Images:
    import java.awt.*;
    import java.io.*;
    import javax.swing.ImageIcon;
    public class objCreateAppletImage
    public void objCreateAppletImage ()
    //If an error occurs (or is thrown by me) it will be thrown to the next level up, and either caught or thrown
    public ImageIcon getImageIcon (Object parentClass, String path, String description, int fileSize) throws Exception
    int count = 0;
    BufferedInputStream imgStream = new BufferedInputStream(parentClass.getClass().getResourceAsStream(path));
    byte buff[] = new byte[fileSize];
    if (imgStream == null) //If doesn't exist
    throw new Exception("File not Found");
    try
    count = imgStream.read(buff);
    imgStream.close(); //Closes the stream
    catch (IOException ex)
    throw new Exception("Corrupt file");
    return new ImageIcon(Toolkit.getDefaultToolkit().createImage(buff), description); //Creates the image from the byte array
    }Could someone please help me? I really have no idea and I would like this to work.
    Thank you
    Frank

    Oh, thank you. I will not do that in the future.
    I am not entirely sure how I would use the getImage method in an Applet. I would prefer to just use the code that I have currently, unless the addition of making the program an Applet only adds a small amount of code. But then even still, I am not entirely sure what I would write in the .class file to make the images load. And then I would not really know how to properly incorporate the pss.java file and the .class file together so they read off of each other.

  • I need help with a basic rock paper scissors program!

    i need to make a program that allows the computer to play rock paper scissors at random and compare the results with user and tell who wins or if its a tie. can anyone help me?

    import java.util.Scanner;
    import java.util.Random;
    public class RockPaperScissors
    public static final int ROCK = 1;
    public static final int PAPER = 2;
    public static final int SCISSORS = 3;
    public static void main(String[] args)
    final int NUM_CHOICES = 3;
    Random generator = new Random();
    int userWins = 0;
    int compWins = 0;
    int ties = 0;
    int compChoice, userChoice;
    boolean exit = false;
    Random randGen = new Random();
    Scanner scan = new Scanner(System.in);
    System.out.println("Enter your choice: ");
    userChoice = scan.nextInt();
    System.out.println("Computers Choice: ");
    compChoice = scan.nextInt();

  • Need help with a rock paper scissors GUI

    i dont know whats wrong, for some reason the String "human" or String "player" is not responding so i keep getting an error also if anyone can PLZ help me set color for the labels
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.Scanner;
    import java.util.Random;
    public class RPSPanel extends JPanel
       private JLabel inputLabel, outputLabel, resultLabel, statementLabel, newlabel, titlelabel, copyrightlabel;
       private JTextField player;
       private JButton input;
       public RPSPanel()
          titlelabel = new JLabel ("**************************Rock Paper Scissors v1.52.22*************************");     
          inputLabel = new JLabel ("Enter Rock Paper or Scissors :");
          outputLabel = new JLabel ("Computers Choice: ");
          player = new JTextField (9);
          resultLabel = new JLabel ("-----------");
          statementLabel = new JLabel("---------------------------------------------------------------------");
          newlabel = new JLabel("*******************************************************************************");
          copyrightlabel = new JLabel("copyright 2007. msg inc");
          input = new JButton ("PLAY!");
          input.addActionListener (new playerlistener());
          add (titlelabel);
          add (inputLabel);
          add (player);
          add (outputLabel);
          add (resultLabel);
          add (statementLabel);
          add (input);
          add (newlabel);
          add (copyrightlabel);
          setPreferredSize (new Dimension(300, 175));
          setBackground (Color.black);
       private class playerlistener implements ActionListener
          public void actionPerformed (ActionEvent event)
             Random generator = new Random();     
        int lol;
        String human = player.getText();
        String comp = "";
        String result = "";
             lol = generator.nextInt(3) + 1;
           switch (lol)
                 case 1:
                 comp = "rock";
                 break;
                 case 2:
                comp = "paper";
                break;
                case 3:
                comp = "scissors";     
                 break;
             if(comp.equals(human))
               statementLabel.setText("---------------------------tie. try again-------------------------------------");
             if(human.equals("rock") && comp.equals("paper"))
                  statementLabel.setText("------------------------paper beats rock. YOU SUCK!-------------------------");
             if(human.equals("rock") && comp.equals("scissors"))
              statementLabel.setText("--------------------------rock beats scissors. is very nice---------------------------");
             if(human.equals("paper") && comp.equals("rock"))
               statementLabel.setText("--------------------------paper beats rock. you win--------------------------");
             if(human.equals("paper") && comp.equals("scissors"))
                statementLabel.setText("---------------------scissors beats paper. you n00b-----------------------");
             if(human.equals("scissors") && comp.equals("rock"));
                 statementLabel.setText("----------------------rock beats scissors. owned----------------------------");
             if(human.equals("scissors") && comp.equals("paper"))
                statementLabel.setText("----------------------scissors beats paper. you win-----------------------");
             else
                statementLabel.setText("---------------------------------error----------------------------------");   
             resultLabel.setText(comp);
    }Message was edited by:
    msg256

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.Scanner;
    import java.util.Random;
    public class RPS extends JPanel
       private JLabel inputLabel, outputLabel, resultLabel,
                      statementLabel, newlabel, titlelabel, copyrightlabel;
       private JTextField player;
       private JButton input;
       public RPS()
          titlelabel = getLabel ("**************************Rock Paper Scissors v1.52.22*************************");     
          inputLabel = getLabel ("Enter Rock Paper or Scissors :");
          outputLabel = getLabel ("Computers Choice: ");
          player = new JTextField (9);
          resultLabel = getLabel ("-----------");
          statementLabel = getLabel("---------------------------------------------------------------------");
          newlabel = getLabel("*******************************************************************************");
          copyrightlabel = getLabel("copyright 2007. msg inc");
          input = new JButton ("PLAY!");
          input.addActionListener (new PlayerListener());
          add (titlelabel);
          add (inputLabel);
          add (player);
          add (outputLabel);
          add (resultLabel);
          add (statementLabel);
          add (input);
          add (newlabel);
          add (copyrightlabel);
          setPreferredSize (new Dimension(300, 175));
          setBackground (Color.black);
       private JLabel getLabel(String s)
          JLabel label = new JLabel(s);
          label.setForeground(Color.red);
          return label;
       private class PlayerListener implements ActionListener
          Random generator = new Random();
          public void actionPerformed (ActionEvent event)
             String human = player.getText().toLowerCase();
             String comp = "";
             String dash = "---------------";
             int lol = generator.nextInt(3) + 1;
             switch (lol)
                case 1:
                   comp = "rock";
                   break;
                case 2:
                   comp = "paper";
                   break;
                case 3:
                   comp = "scissors";
                   break;
                if(comp.equals(human))
                   statementLabel.setText(dash + "tie. try again" + dash);
             else if(human.equals("rock") && comp.equals("paper"))
                statementLabel.setText(dash + "paper beats rock. YOU SUCK!" + dash);
             else if(human.equals("rock") && comp.equals("scissors"))
                statementLabel.setText(dash + "rock beats scissors. is very nice" + dash);
             else if(human.equals("paper") && comp.equals("rock"))
                statementLabel.setText(dash + "paper beats rock. you win" + dash);
             else if(human.equals("paper") && comp.equals("scissors"))
                statementLabel.setText(dash + "scissors beats paper. you n00b" + dash);
             else if(human.equals("scissors") && comp.equals("rock")) // << ";" !
                statementLabel.setText(dash + "rock beats scissors. owned" + dash);
             else if(human.equals("scissors") && comp.equals("paper"))
                statementLabel.setText(dash + "scissors beats paper. you win" + dash);
             else
                statementLabel.setText(dash + "error" + dash);   
             resultLabel.setText(comp);
       public static void main(String[] args)
          JFrame f = new JFrame();
          f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          f.getContentPane().add(new RPS());
          f.pack();
          f.setVisible(true);
    }

  • Help with Rock, Paper, Scissors Program

    I need some help with my program, I got understand writing each of the methods I have to do but then i don't understand how to piece it together to make the program work. in the main method...I didn't complete the scrolling message method I just wanted to get the game itself working first then I was going to complete that method. I just need to know if I'm heading in the right direction or if i did something completly wrong
    import javax.swing.*;
    public class RockPaperScissors
         public static void displayScrollingMessage (String list)
              String header = "Game #\tUser\tComputer\tWinner\t";
         public static void getUserChoice ( )
              int game = 1;
              for ( game = 1; game > 0 ; game ++)
                   String input = JOptionPane.showInputDialog ("Choose Rock, Paper, or Scissors\n Enter\n 1 for Rock" +
                                                                                              "\n2 for Paper\n3 for Scissors\n4 to Exit");
                   String list = "   ";
                   int option = Interger.parseInt (input);
                   switch (option)
                        case 1:
                                  int userChoice = 1;
                                  getComputersChoice ();
                                  itemName (userChoice);
                                  itemName2 (computersChoice);
                                  whowins (userChoice, computersChoice);
                                  winnerName (winner);
                                  winlose (winner);
                                  String list =+ game + "/t" + itemName + "\t" + itemName2 + "\t" + winnerName + "\n";
                                  String winner = JOptionPane.showOutputDialog (null, "You picked " + itemName + " and the computer picked "
                                                                                                                  + itemName2 + "\nTherefore " + winlose);
                                  return userChoice;
                                  break;
                        case 2:
                                  userChoice = 2;
                                  getComputersChoice ();
                                  itemName (userChoice);
                                  itemName2 (computersChoice);
                                  whowins (userChoice, computersChoice);
                                  winnerName (winner);
                                  winlose (winner);
                                  String list =+ game + "\t" + itemName + "\t" + itemName2 + "\t" + winnerName + "\n";
                                  String winner = JOptionPane.showOutputDialog (null, "You picked " + itemName + " and the computer picked "
                                                                                                                  + itemName2 + "\nTherefore " + winlose);
                                  return userChoice;
                                  break;
                        case 3:
                                  userChoice = 3;
                                  getComputersChoice ();
                                  itemName (userChoice);
                                  itemName2 (computersChoice);
                                  whowins (userChoice, computersChoice);
                                  winnerName (winner);
                                  winlose (winner);
                                  String list =+ game + "\t" + itemName + "\t" + itemName2 + "\t" + winnerName + "\n";
                                  String winner = JOptionPane.showOutputDialog (null, "You picked " + itemName + " and the computer picked "
                                                                                                                  + itemName2 + "\nTherefore " + winlose);                              
                                  return userChoice;
                                  break;
                        case 4:
                                  break;
                        default:
                             JOptionPane.showMessageDialog (null, "Error!! Please enter a valid option!"
                                                                                              , JOptionPane.WARNING_MESSAGE);
                        break;
         public static int getComputersChoice ()
              int computersChoice = (int) (3 * Math.random() + 1);
              return computersChoice;
         public static String itemName (int userChoice)
              if (userChoice == 1)
                   String itemName = Rock;
              else
                   if (userChoice == 2)
                        String itemName = Paper;
                   else
                        if (userChoice == 3)
                             String itemName = Scissors;
              return itemName;
              public static string itemName2 (int computersChoice)
              if (computersChoice == 1)
                   String itemName2 = Rock;
              else
                   if (computersChoice == 2)
                        String itemName2 = Paper;
                   else
                        if (computersChoice == 3)
                             String itemName2 = Scissors;
              return itemName2;
         public static string winlose (int winner)
              if (winner == 1)
                   winlose = "You Win!!!";
              else
              if (winner == 2)
                   winlose = "You Lose!!";
              else
              if (winner == 3)
                   winlose = "Its a Tie!!";
         return winlose;
         public static string winnerName (int winner)
              if (winner == 1)
                   String winnerName = "User";
              else
              if (winner == 2)
                   String winnerName = "Computer";
              else
              if (winner == 2)
                   String winnerName = "Tie";
              return winnerName;
         public static void whoWins (int computersChoice, int userChoice)
              if (userChoice == 1 && computersChoice == 1)
                   int winner = 3;
              else
              if (userChoice == 1 && computersChoice == 2)
                   int winner = 2;
              else
              if (userChoice == 1 && computersChoice == 3)
                   int winner = 1;
              else
              if (userChoice == 2 && computersChoice == 1)
                   int winner = 1;
              else
              if (userChoice == 2 && computersChoice == 2)
                   int winner = 3;
              else
              if (userChoice == 2 && computersChoice == 3)
                   int winner = 2;
              else
              if (userChoice == 3 && computersChoice == 1)
                   int winner = 2;
              else {
              if (userChoice == 3 && computersChoice == 2)
                   int winner = 1;
              else
              if (userChoice == 3 && computersChoice == 3)
                   int winner = 3;
              return winner;
         public static void main (String args [])
              getUserChoice ( );
              System.exit (0);
    }

    Here's something to compare to
    import javax.swing.*;
    public class RockPaperScissors
      public RockPaperScissors()
        String[] pick = {"Rock","Paper","Scissors","Exit"};
        int user = 0, computer = 0;
        String result = "", output = "";
        while(user < 3)
          user = JOptionPane.showOptionDialog(null,"Which do you want?",
                               "Rock-Paper-Scissors",-1,-1,null,pick,"");
          if(user == 3) break;
          computer = (int)(3*Math.random());
          result = getWinner(user,computer);
          output = "You chose "+pick[user] + "\nComputer chose " + pick[computer]+
                   "\n\nResult:- " + result;
          JOptionPane.showMessageDialog(null,output);        
        System.exit(0);
      public String getWinner(int player, int comp)
        if(Math.abs(player - comp) > 1)
          if(player == 2) player = -1;
          if(comp == 2) comp = -1;
        return player > comp? "You win.":player < comp? "Computer wins.":"Tie.";
      public static void main(String[] args){new RockPaperScissors();}
    }

  • Java newbie (what's could be wrong with this program?)

    First things first, I just started programming with JAVA recently so please forgive me if it seems stupid. Since I am so relatively new to the language, in order to get a feel for it I started running some simple scripts. I can compile and execute most of them without any problem. However when I tried to compile this one I get a couple of errors I am not familiar with. So my question is what could be wrong and what needs to be changed in order to get it to work? or if the syntax is correct could there be some other problem?
    On a side note, I am coming more from a C and C++ background so if anyone can recommend a way to start learning the JAVA language from a prespective in C that would be highly appreciated.
    System Environment: I am using j2sdk1.4.2 on a Windows 2000 machine running SP3.
    If anything else needs further clarification please let me know.
    |------------------------- The Code -----------------------------------|
    package RockPaperScissors;
    import java.util.HashMap;
    public class RockPaperScissors {
    String[] weapons = {"Rock", "Paper", "Scissors"};
    EasyIn easy = new EasyIn();
    HashMap winners = new HashMap();
    String playerWeapon;
    String cpuWeapon;
    int cpuScore = 0;
    int playerScore = 0;
    public static void main(String[] args) {
    RockPaperScissors rps = new RockPaperScissors();
    boolean quit = false;
    while (quit == false) {
    rps.playerWeapon = rps.getPlayerWeapon();
    rps.cpuWeapon = rps.getCpuWeapon();
    System.out.println("\nYou chose: " + rps.playerWeapon);
    System.out.println("The computer chose: " + rps.cpuWeapon + "\n");
    rps.getWinner(rps.cpuWeapon, rps.playerWeapon);
    if (rps.playAgain() == false) {
    quit = true;
    System.out.println("Bye!");
    public RockPaperScissors() {
    String rock = "Rock";
    String paper = "Paper";
    String scissors = "Scissors";
    winners.put(rock, scissors);
    winners.put(scissors, paper);
    winners.put(paper, rock);
    System.out.println("\n\t\tWelcome to Rock-Paper-Scissors!\n");
    public String getPlayerWeapon() {
    int choice = 6;
    String weapon = null;
    System.out.println("\nPlease Choose your Weapon: \n");
    System.out.println("1. Rock \n2. Paper \n3. Scissors \n\n0. Quit");
    try {
    choice = easy.readInt();
    } catch (Exception e) {
    errorMsg();
    return getPlayerWeapon();
    if (choice == 0) {
    System.out.println("Quitting...");
    System.exit(0);
    } else {
    try {
    weapon = weapons[(choice - 1)];
    } catch (IndexOutOfBoundsException e) {
    errorMsg();
    return getPlayerWeapon();
    return weapon;
    public void errorMsg() {
    System.out.println("\nInvalid Entry.");
    System.out.println("Please Select Again...\n\n");
    public String getCpuWeapon() {
    int rounded = -1;
    while (rounded < 0 || rounded > 2) {
    double randomNum = Math.random();
    rounded = Math.round(3 * (float)(randomNum));
    return weapons[rounded];
    public void getWinner(String cpuWeapon, String playerWeapon) {
    if (cpuWeapon == playerWeapon) {
    System.out.println("Tie!\n");
    } else if (winners.get(cpuWeapon) == playerWeapon) {
    System.out.println("Computer Wins!\n");
    cpuScore++;
    } else if (winners.get(playerWeapon) == cpuWeapon) {
    System.out.println("You Win!\n");
    playerScore++;
    public boolean playAgain() {
    printScore();
    System.out.print("\nPlay Again (y/n)? ");
    char answer = easy.readChar();
    while (true) {
    if (Character.toUpperCase(answer) == 'Y') {
    return true;
    } else if (Character.toUpperCase(answer) == 'N') {
    return false;
    } else {
    errorMsg();
    return playAgain();
    public void printScore() {
    System.out.println("Current Score:");
    System.out.println("Player: " + playerScore);
    System.out.println("Computer: " + cpuScore);
    |------------------------- Compiler Output ----------------------------|
    C:\ide-xxxname\sampledir\RockPaperScissors>javac RockPaperScissors.java
    RockPaperScissors.java:8: cannot resolve symbol
    symbol : class EasyIn
    location: class RockPaperScissors
    EasyIn easy = new EasyIn();
    ^
    RockPaperScissors.java:8: cannot resolve symbol
    symbol : class EasyIn
    location: class RockPaperScissors
    EasyIn easy = new EasyIn();
    ^
    2 errors

    limeybrit9,
    This importing certainly seems to be the problem, I'm still not used to how compilation works within the JAVA language, I'll play around with it a bit and see if I can get it to work correctly.
    bschauwe,
    The C++ approach has certainly clarified some of the points. I guess I will be sticking to that.
    bsampieri,
    You were correct on the class looking rather generic, but as I mentioned before I was just sort of tinkering to see if I could get it to work.
    Thanks to all for the help, very much appreciated.

  • Mac mini (mid 2011) to Samsung led tv via hdmi connection problem.

    Samsung led tv - UE32D5000
    Mac mini (mid 2011)
    On regular monitor (connected by hdmi to dvi cable) setup teamviewer
    Try to:
    1. Connect different hdmi cables - dose not work (on apple tv - both cables work)
    2. Connect hdmi cable to different hdmi ports.
    3. On tv change type of source - PC, PC-DVI and other.
    By teamviewer I watched what was going on the computer - Mac mini does not recognize tv like monitor by pressing 'seek monitor'.

    Aha! Similar problem here; Mini (Intel, Macmini2,1, the 2007 version with the larger HDI port not the smaller one)
    Problem seems to happen only with both HDMI and USB connected (USB only to use the built-in webcam on the monitor, an AOC V22+ (which I love, it's a very nice monitor; LED instead of fluorescent backlight).
    Sometimes it would suddenly switch to where the dock and menu bars and status bar were hidden (the desktop gets 'too big for the screen).
    Then I'd go to the Display settings and unselect "overscan"
    Then it'd be OK for a while, then switch to a big black space around the desktop window, lots of unused screen).
    Then I'd go to the Display settings and reselect "overscan" and it'd be Ok.
    For a while.
    There really ought not be a need to fiddle with 'overscan' at all -- since I'm not using this as a television. Mac OS 10.3.6 seems to mistakenly think the monitor is being used as a TV -- maybe when there's a video in a browser window?
    Not sure.
    Anyhow it becomes a rock-paper-scissors problem where I have to keep chasing the settings to undo whatever it changes to at random, Lather rinse repeat.
    Seems like it's only a problem for me when I have the USB cable also connected, to use the built-in webcam -- so I don't use that now.
    The AOC folks have been working hard on solving this.
    I just found this topic and have referred them here.
    They'll be glad to know it's not their problem, I guess.
    (does it happen on Apple brand displays too? I'm not sure)

  • My 3G iPhone takes 6 hours to sync.

    Every single time I plug my 3G phone in, I have to wait 6 hours for it to finish a backup and sync. How is this possibly acceptable and when will it be fixed?
    I have the following apps installed:
    Band
    Banner Free
    BeatMaker
    BlackJack21
    Bloomberg
    Break: 99 levels
    eBay Mobile
    Facebook
    Google Mobile App
    Labyrinth Lite Edition
    Last.fm
    Now Playing
    Pandora
    PhoneSaber
    Pianist
    Sketches
    SmugShot
    SuperMonkeyBall
    Tap Tap Revenge
    Texas Hold'em
    Twitterific
    Other information:
    iTunes claims that I have 2 applications that have updates available. But when I click the "updates" arrow, iTunes then claims there are no available updates (bug)
    I have 83 megs of photos, 1.17 gb of videos, 700mb of audio, and 718.5mb of "other". 12gb free.
    I've deleted every app on the device and reinstalled them one at a time from iTunes. Same problem.
    I've nuked the phone back to factory and started from scratch. Same problem.
    My phone has less than 2 gigs of data used. I can't even imagine what it could POSSIBLY be doing for 6 hours?! There is no reason in the WORLD backing up a mobile device (even if it was FULL to 16 gigs) should take more than 20 minutes over USB 2.0.
    When will this be fixed?

    well, ive spent an absolute fortune at itunes for my iphone, and....
    sync: 9 hours
    restore: 9 hours
    no, i aint lying.... i have tons of stuff on my iphone.
    its great when its all on and working, but ... ONE SINGLE UPDATE, and crash.... apple logo. (back to the times above)
    sometimes, i dont even have to get an update, sometimes.. its trying to sync (via cable) a new app ive just purchased on itunes (on my laptop), CRASH... apple logo.
    app list:
    AirHockey Fingertip Sports
    allRadio
    aSleep
    Aurora Feint: The Beggining
    Band
    Bejeweled 2
    Billy Frontier
    Brain Challenge
    Brain Tuner Premium
    BtBx (beatbox)
    Bubble Bash
    Cannon Challenge
    Chimps Ahoy
    Chopper
    Conversion
    cowabunga
    Crash Bandicoot Nitro Kart
    Critter Crunch
    Cro-Mag Rally
    Cubes
    CubicMan Deluxe
    Dactyl
    De Blob
    Dizzy Bee
    Enigmo
    eWallet
    Facebook
    Face Melter
    Fire Drop
    Fizz Weather
    Funky Punch
    GTS World Racing
    Hairball
    iBeer
    iDrum Club Edition
    iFooty
    ikick
    iLightr
    IM+
    Imagine Poker
    Imangi
    iPint
    Koi Pond
    Labyrinth
    Lucky 7 Slots
    Moonlight Mahjong
    MotionX Poker
    Moto Racer/Chaser
    Multiplayer Championship Poker
    Ninja Adventure
    Numba
    Palringo
    PegJump
    Picoli
    Platinum Solitaire
    Platinum Sudoku
    Pool
    Reel Deal Slots
    Remote
    Rock Paper Scissors
    Shazam
    South Park Imagination Land
    Space Monkey
    StarSmasher
    Super Monkey Ball
    Tap Tap Revenge
    Texas Hold'em
    Toy Bot Diaries
    Tris
    Trism
    Tuner Internet Radio
    Vicinity
    Whack the Groundhog
    3-D Vector Pong
    and will be adding 2 more to that shortly, funnily enough... when my iphone has finished its RESTOREEEEEEEEEEE

  • Trouble compiling code

    I'm trying to write a rock, paper, scissors program but am having trouble converting an integer to its appropriate string. Here is the code I have:
    // Rock.java
    // Play Rock, Paper, Scissors with the user
    import java.util.Scanner;
    import java.util.Random;
    public class Rock
    public static void main(String[] args)
         String personPlay; //User's play -- "R", "P", or "S"
         String computerPlay; //Computer's play -- "R", "P", or "S"
         int computerInt; //Randomly generated number used to determine
         //computer's play
    Scanner scan = new Scanner(System.in);
         Random generator = new Random();
         computerInt = generator.nextInt(3);//Generate computer's play (0,1,2)
         //Translate computer's randomly generated play to string
         switch (computerInt)
         case 0:
              System.out.println ("R");
              break;
         case 1:
              System.out.println ("P");
              break;
         case 2:
              System.out.println ("S");
              break;
    System.out.println ("Enter your play: R, P, or S");//Get player's play from input-- note that this is stored as a string
    personPlay = scan.nextLine();
    personPlay = personPlay.toUpperCase();     //Make player's play uppercase for ease of comparison
    System.out.println ("Computer play is " + computerPlay);     //Print computer's play
         //See who won. Use nested ifs instead of &&.
         if (personPlay.equals(computerPlay))
         System.out.println("It's a tie!");
         else
              if (personPlay.equals("R"))
                   if (computerPlay.equals("S"))
                   System.out.println("Rock crushes scissors. You win!!");
              if (computerPlay.equals("P"));
                   System.out.println("Paper covers rock. You lose");
                   if (personPlay.equals("P"))
                        if (computerPlay.equals("R"))
                        System.out.println("Paper covers rock. You win!!");
                        if (computerPlay.equals("S"))
                                  System.out.println("Scissors cuts paper. You lose");
                   if (personPlay.equals("S"))
                             if (computerPlay.equals("R"));
                                       System.out.println("Rock crushes scissors. You lose");
                             if (computerPlay.equals("P"))
                             System.out.println("Scissors cuts paper. You win!!");
              //... Fill in rest of code
    My compiling error is that the string computerPlay was not initialized.. I think I need to do something more in the switch section of the code but can't figure out what. Thanks ahead of time for any advice!

    soccer89 wrote:
    My compiling error is that the string computerPlay was not initialized.. I think I need to do something more in the switch section of the code but can't figure out what. Thanks ahead of time for any advice!Instead of running System.out.println() set the value in your switch statementl then run
    System.out.println(computerPlay);after it's properly set.
    BTW, rather than a switch statement, you could use
    computerPlay = "RPS".substring(computerInt, computerInt + 1);I'll leave you to work out why.
    Winston

  • If i have an app in FF Market how can i save when user get achivments from my app...

    so, i made an app on FF market called R.C.P. (rock paper scissors) but i want if player won 5 times, 50 times, 500 times etc, to get an achivment BUT when he run again the app he can see his achivments.. if he restart the application the achivments will dissapeard....

    hello, use a technology like localstorage to save the achievements and/or other settings: https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Storage
    some general ressources for webapp developers:
    <br>https://developer.mozilla.org/en-US/docs/Web/Apps
    <br>https://marketplace.firefox.com/developers/docs/game_apps

  • Separating letters in txt file to two different strings

    I have a text file that has the results of rock paper scissors game.
    R P
    S R
    P P
    I need to have the first letter in each line assigned to player1 and the second letter in each line assigned to player 2.
    I have no clue where to start. I have the file input correct. It is reading the file and I can separate ints from strings. I just don't know how to separate the strings.

    1005698 wrote:
    If i had to guess, it would involve putting a ++ somewhere.But you shouldn't be guessing, you should be knowing. You say you want to SEPARATE a String. So what is stopping you from typing "java separate string" into Google? You get some interesting results I can tell you.
    When I was learning and I needed to do something very specific my first stop was always the javadocs. In this case you want to separate (or "split") a String, so a logical place to look would be the javadoc for the String class. Easy to get to, just type "java 7 String" into google and off you go.
    http://docs.oracle.com/javase/7/docs/api/java/lang/String.html
    And then its a question of scanning the available method names to see one that might fit your needs. Don't understand how to properly use it? Google it! The whole world uses Java, you have a rich history of examples and articles at your disposal that I certainly did not have when I started out. Use it, please.

  • Turning java code into a format I can include on a web page?

    I made a java program to play rock paper scissors with analog boxes, but I want to format it so that I can put it on my website. how do i do this?

    I'm really new at this entire java thing, so i'm not
    sure how to make an applet or anything like that :-\http://java.sun.com/docs/books/tutorial/uiswing/components/applet.html

  • What is the best hardware and network setup?

    Hi
    I'm looking for the best setup for my hardware to go with CC
    I mainly edit from RED files.  I transcode the files to ProRes HQ or Proxy (depending on volume), then edit in Premiere and After Effects.
    I have the new Mac Pro and 2 Pegasus RaIDS - 18TB and 6TB.  However as I was losing so much time waiting for Transcodes to complete and for AE files to render, I bought a 2nd Mac Pro so I can use 1 for editing and 1 for Transcode / Render.
    Now to me, this seemed simple and having watched this - Adam Pertofsky, editorand partner, Rock Paper Scissors Pro video editing apps and tools | Adobe Creative Cloud - and having worked in numerous edit suites over the years, it should be straightforward, right?  However I have now spent 5 days in discussion with Apple going from Enterprise to Servers to CPU divisions and they don't seem to understand what I want.
    Can someone tell me what is the best way to set this up in a simple, effective way, so I can get back to editing?
    Many thanks
    Ian

    " I'm currently using CS4 but would like to upgrade"
    IF THE UPGRATE IS TO CS5 64 BITS. Better to work with quad core with H.T. like i7 920,930,950. If you like somthing faster we talk about i7 970,980x, 990.
    RAM: If you will work with heavy files, start with 12G RAM  3x4. So you have the possibility to upgrate after to 24 if you need it.
    "graphics card"
    Nvidia card: GTX460, GTX470. NO NEED TO GO TO SERIES GTX5..
    "hard drive"  many choises. Depent of what performance you want, This can incrise the price a loot.
    "monitors" I will say samsung 23, the are sheep and if you like you can have 2 monitor on each PC.
    How many PC'S YOU NEED??
    B.R.
    Cristobal

  • How to handle modules in OOP

    Hi,
    I am writing a simple Rock-Paper-Scissors program and I read a lot of basic stuff so far, also read some parts of Code Complete, but I still have some basic questions about the structure of an OOP program:
    - If I have "module" of the program (for example that calculates the computer's choice in my Rock-Paper program based on my previous choices) that is too big to put it into a method, do I have to create a class for it? For what I read so far, classes are not to pack some part of the code together, but I don't how else could I handle a module of a program. In my Rock-.. program I would call it Calculator, I think it's ok, for example I've seen java.util.Scanner, which is some kind of "doer" packed in a class, too.
    - But if I create this class, it would not be a blueprint for objects. I only need one object, so should I use that so called singleton pattern?
    - Or should I make every field in this object static instead of the singleton pattern?
    (I also don't know what the Main class and main() method should usually contain, I don't know if this connects to this in any way, so this might be another topic..)
    Thanks in advance for any help.

    lemonboston wrote:
    Hi,
    I am writing a simple Rock-Paper-Scissors program and I read a lot of basic stuff so far, also read some parts of Code Complete, but I still have some basic questions about the structure of an OOP program:
    - If I have "module" of the program (for example that calculates the computer's choice in my Rock-Paper program based on my previous choices) that is too big to put it into a method, do I have to create a class for it? For what I read so far, classes are not to pack some part of the code together, but I don't how else could I handle a module of a program. In my Rock-.. program I would call it Calculator, I think it's ok, for example I've seen java.util.Scanner, which is some kind of "doer" packed in a class, too.
    I'm not 100% sure if you are using the right terminology. I normally think of a module as a grouping of functionality, in Java normally a series of classes (more likely a group of packages).
    Generally, if logic is too complex, you need to break it into smaller, discrete pieces. Ideally, each method does one thing and only one thing well. This has nothing per se to do with OOP. You could do the same procedurally with namespaces (or packages or whatever they offer) and organizing your source files.
    Within Java, you would have the option of breaking your larger method into smaller (likely private) methods. Then once you see that different methods have different responsibilities, you may refactor your design into separate classes.
    - But if I create this class, it would not be a blueprint for objects. I only need one object, so should I use that so called singleton pattern?Are you talking classes or objects? Your design may need one or more classes. A singleton is a pattern that when implemented ensures at runtime that only one instance (object) of a class exists in a given JVM.
    - Or should I make every field in this object static instead of the singleton pattern?
    I think you are conflating things here. What is motivating you to make something static?
    (I also don't know what the Main class and main() method should usually contain, I don't know if this connects to this in any way, so this might be another topic..)
    Yes, another topic. The class can be named anything. It simply needs a main() method with a valid signature to act as an application entry point.
    Thanks in advance for any help.You are welcome.
    - Saish

  • SetLocation not working right

    In the following code I am using a setLocation to position the scores and related info for a rock paper scissors game. the first time a button is pressed the info displays in the correct location. However subsequent button presses result in the info going back to the default locations from the flowLayout. The setLocation is near the very end of the code in the actionPerformed method.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class JRockPaperScissors extends JApplet implements ActionListener
         int tie = 0;
         int you = 0;
         int computer = 0;
         JLabel header = new JLabel("Rock, Paper, Scissors");
         JLabel command = new JLabel("Click one button");
         JLabel results = new JLabel("-----Results-----");
         JLabel resultCaption = new JLabel("");
         JLabel picks = new JLabel("");
         JLabel score = new JLabel("");
         Font headerFont = new Font("Helvetica", Font.BOLD, 36);
         Font commandFont = new Font("Helvetica", Font.BOLD, 18);
         JButton rock = new JButton("Rock");
         JButton paper = new JButton("Paper");
         JButton scissors = new JButton("Scissors");
         Container con = getContentPane();
         public void init()
              header.setFont(headerFont);
              command.setFont(commandFont);
              con.add(header);
              con.add(command);
              con.add(rock);
              con.add(paper);
              con.add(scissors);
              con.setLayout(new FlowLayout());
              rock.addActionListener(this);
              paper.addActionListener(this);
              scissors.addActionListener(this);
         public void actionPerformed(ActionEvent e)
              Object source = e.getSource();
              final int ROCK = 1;
              final int PAPER = 2;
              final int SCISSORS = 3;
              int yourSelect;
              int compSelect = ((int)(Math.random() * 100) % 3 + 1);
              if(source == rock)
                   if(compSelect == ROCK)
                        resultCaption.setText("Winner: No one, it's a tie");
                        picks.setText("You picked Rock; --- Computer picked Rock");
                        tie = tie + 1;
                   if(compSelect == PAPER)
                        resultCaption.setText("Winner: Computer");
                        picks.setText("You picked Rock --- Computer picked Paper");
                        computer = computer + 1;
                   if(compSelect == SCISSORS)
                        resultCaption.setText("Winner: You");
                        picks.setText("You picked Rock --- Computer picked Scissors");
                        you = you + 1;
              if(source == paper)
                   if(compSelect == ROCK)
                        resultCaption.setText("Winner: You");
                        picks.setText("You picked Paper; --- Computer picked Rock");
                        you = you + 1;
                   if(compSelect == PAPER)
                        resultCaption.setText("Winner: No one, it's a tie");
                        picks.setText("You picked Paper; --- Computer picked Paper");
                        tie = tie + 1;
                   if(compSelect == SCISSORS)
                        resultCaption.setText("Winner: Computer");
                        picks.setText("You picked Paper; --- Computer picked Scissors");
                        computer = computer + 1;
              if(source == scissors)
                   if(compSelect == ROCK)
                        resultCaption.setText("Winner: Computer");
                        picks.setText("You picked Scissors; --- Computer picked Rock");
                        computer = computer + 1;
                   if(compSelect == PAPER)
                        resultCaption.setText("Winner: You");
                        picks.setText("You picked Scissors; --- Computer picked Paper");
                        you = you + 1;
                   if(compSelect == SCISSORS)
                        resultCaption.setText("Winner: No one, it's a tie");
                        picks.setText("You picked Scissors; --- Computer picked Scissors");
                        tie = tie + 1;
              score.setText("you: " + you + "  Computer: " + computer + "  Tie: " + tie);
              con.add(results);
              con.add(picks);
              con.add(resultCaption);
              con.add(score);
              validate();
              results.setLocation(10,100);
              picks.setLocation(10,120);
              resultCaption.setLocation(10,140);
              score.setLocation(10,160);
    }Sorry I'm a total noob.. Any Ideas or suggestions?
    Thanks.

    K, I placed the setLayout(null); right at the end and now the placement is correct but the resultCaption gets truncated, ie; Winner: Comp... instead of Winner: Computer.

Maybe you are looking for