Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can we put reportCompareAll()method in RockPaperScissorDemo class instead of Roc

ID: 3658768 • Letter: C

Question

Can we put reportCompareAll()method in RockPaperScissorDemo class instead of RockPaperScissors class? What types of change is needed for it to work? Provide your reason for why yes or why not. RockPaperScissorsDemo import javax.swing.JOptionPane; // Flavor of use GUI: http://docs.oracle.com/javase/tutorial/uiswing/components/index.html public class RockPaperScissorsDemo { // This program will play RockPaperScissors game with player. public static void main(String[] args) { final int NUM_GAMES = 5; // total number of games int gameCount = 0; // counter for games RockPaperScissors[] record = new RockPaperScissors[NUM_GAMES]; // save game result in array // http://www.leepoint.net/notes-java/GUI/containers/20dialogs/10joptionpane.html JOptionPane.showMessageDialog(null, "You are about to play " + NUM_GAMES + " rochambeau with computer"); // The result of game will be saved in a array while(gameCount < NUM_GAMES) { record[gameCount] = new RockPaperScissors(); gameCount++; } // end while(gameCount // Call RockPaperScissors class to display info. for us. RockPaperScissors.reportCompareAll(record); System.exit(0); } // end main } // end RockPaperScissorsDemo class RockPaperScissors class import javax.swing.JOptionPane; // Flavor of use GUI: http://docs.oracle.com/javase/tutorial/uiswing/components/index.html public class RockPaperScissors { private String userPick; // store what user pick - rock, paper, or scissors private String computerPick; // store what computer pick - rock, paper, or scissors // Constructor // Call userHand() to request player given input. // Call computerHand() to generate computer input. // Store result in the userPick and computerPick fileds. public RockPaperScissors() { userPick = userHand(); computerPick = computerHand(); } // end RockPaperScissors() // request player given input private String userHand() { String instructions = ": Type one of the following : (R)ock (P)aper (S)cissors"; String userSelect = ""; // reset userSelect result // Make sure player pick a valid option. while(userSelect.equals("")) { // display message http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/JOptionPane.html#showInputDialog(java.awt.Component, java.lang.Object) userSelect = JOptionPane.showInputDialog(null, instructions); // save return to userSelect userSelect = userSelect.toLowerCase(); // convert all userSelect characters to lower case switch(userSelect.charAt(0)) { case 'r': userSelect = "rock"; break; case 'p': userSelect = "paper"; break; case 's': userSelect = "scissors"; break; default: JOptionPane.showMessageDialog(null, "You must pick (r)ock, (p)aper or (s)cissors instead of " + userSelect); userSelect = ""; break; } // end switch(userSelect.charAt(0)) } // end while(userSelect.equals("")) return userSelect; } // userHand() method // Let computer pick up a valid option // with Math.ramdom() http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Math.html#random() private String computerHand() { final int HIGH = 3; // select between rock, paper, and scissors int computer = (int)((Math.random() * 100) % HIGH); String compSelect = ""; // reset computer select result switch (computer) { case 0: compSelect = "rock"; break; case 1: compSelect = "paper"; break; case 2: compSelect = "scissors"; break; } // end switch (computer) return compSelect; } // end computerHand()method // Compare and return the result between player and computer and determine winner or tie private String compareResult() { String compareResult = ""; // reset compareResult if (userPick.equals(computerPick)) compareResult = "tie"; else if (userPick.equals("rock")) { if(computerPick.equals("paper")) compareResult = "computer"; else compareResult = "player"; } else if (userPick.equals("paper")) { if(computerPick.equals("rock")) compareResult = "player"; else compareResult = "computer"; } else if (userPick.equals("scissors")) { if(computerPick.equals("paper")) compareResult = "player"; else compareResult = "computer"; } // end start if .. else if System.out.printf("user:%s computer:%s compareResult:%s ", userPick, computerPick, compareResult); return compareResult; } // end compareResult() method // Go through each result public static String reportCompareAll(RockPaperScissors record[]) { int computerWon = 0; // counter for computer win int playerWon = 0; // counter for player win int tieGames = 0; // counter for game time String msg = "#: Computer Player "; String temp; for (int i = 0; i < record.length; i++) { temp = record[i].compareResult(); if(temp.equals("computer")) computerWon++; else if (temp.equals("player")) playerWon++; else tieGames++; msg = msg + i + ": " + record[i].computerPick + " " + record[i].userPick + " "; } // end for (int i // Display final result. JOptionPane.showMessageDialog(null, msg + " End of " + record.length + " games You won " + playerWon + " games Computer won " + computerWon + " games There were " + tieGames + " tie games"); return msg; } // end reportCompareAll() method } // end RockPaperScissors class

Explanation / Answer

no, your blood type is your blood type for your entire life span. Your blood type also affects your organs etc should a transplant be needed. FYI, you also could never get a transfusion of blood that does not match your own. It could lead to severe complications and even be fatal. The only change to bloodtype that can occur is a switch from Negative (-) blood to Positive (+) blood. This is due to the development of antibodies to the + bloodtype. This process cannot be reversed however, going from Positive (+) to Negative (-). The process is most common in pregnant women or new mothers, when the fetus carries Positive, and the mother Negative. In the event the baby carries Negative, and the mother carries Positive, a medical injection is required to prevent the mother's immune system from attacking the fetus.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote