Question: I need JUnit tests for this program ( 2 that test RandomDeck and 2 that test DeckList ) import java.util.Random; import java.util.Scanner; public class DeckHelp

I need JUnit tests for this program (2 that test RandomDeck and 2 that test DeckList)
import java.util.Random;
import java.util.Scanner;
public class DeckHelp {
static String DeckChoice;
static String List;
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.println("Please enter which function you'd like (Random or List): ");
String FunctionChoice = sc.nextLine();
if(FunctionChoice.equals("Random")|| FunctionChoice.equals("random")){
RandomDeck();
}
else if(FunctionChoice.equals("List")|| FunctionChoice.equals("list")){
DeckList();
}
else{
System.out.println("Invalid Input. Please restart the program.");
}
}
public static String RandomDeck(){
Random Rand = new Random();
int DeckNum = Rand.nextInt(3);
if(DeckNum ==0){
DeckChoice = "Rapid";
System.out.println("You will run Rapid today. Make them fear the bunnies.");
}
if(DeckNum ==1){
DeckChoice = "Hunters";
System.out.println("You will run Hunters today. Overwhelm the board with bodies.");
}
if(DeckNum ==2){
DeckChoice = "Imperial";
System.out.println("You will run Imperial today. Hit the funny Dragon Mode into ST Paildramon combo again.");
}
if(DeckNum ==3){
DeckChoice = "Gallant";
System.out.println("Finish Gallant and run it you coward.");
}
return DeckChoice;
}
public static String DeckList(){
Scanner sc = new Scanner(System.in);
System.out.println("Please enter which deck you'd like to see (Rapid, Imperial, Hunters, or Gallant): ");
String ListChoice = sc.nextLine();
if(ListChoice.equals("Rapid")|| ListChoice.equals("rapid")){
System.out.println("[List]");
List = "Rapid";
}
else if(ListChoice.equals("Imperial")|| ListChoice.equals("imperial")){
System.out.println("[List]");
List = "Imperial";
}
else if(ListChoice.equals("Hunters")|| ListChoice.equals("hunters")){
System.out.println("[List]");
List = "Hunters";
}
else if(ListChoice.equals("Gallant")|| ListChoice.equals("gallant")){
System.out.println("[List]");
List = "Gallant";
}
else{
System.out.println("Invalid Input. Please restart the program.");
}
return List;
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!