Untitled
unknown
plain_text
3 years ago
4.6 kB
32
Indexable
// Race info taken from https://www.dndbeyond.com/compendium/rules/basic-rules/races
// Class info taken from https://www.dndbeyond.com/characters/classes
// Alignment info taken from https://www.dndbeyond.com/compendium/rules/basic-rules/personality-and-background#Alignment
import java.util.Scanner;
public class LabMoreDecisions{
/*
This is not one single program but rather snippets of code that might be
included in methods inside a class
Work your way progressively through the tasks as instructed in comments
Work on ONE task at a time.
*/
public static void main (String [] args)
{
Scanner in = new Scanner(System.in);
// ********************* COLOR CHECK
System.out.println("Enter a color");
String color = in.nextLine();
color = color.toLowerCase();
boolean isMardiColor = color.equals("purple") || color.equals("gold") || color.equals("green");
if (isMardiColor){
System.out.println("Happy Madi Gras");
}
else{
System.out.println("That's not a Mardi Gras color");
}
//Write code that will print "That's not a Mardi Gras color" if the user
//enters any color other than purple, gold or green,
//and prints "Happy Madi Gras" if one of the 3 colors is input.
// *************** TASK INPUT VALIDATION
System.out.println("\n\n*** TASK Input Validation \n");
System.out.println("Enter a number between 1 and 100");
int num = in.nextInt();
//Write code that will print "Valid" or "Invalid" based on the number input
boolean isValid = num > 1 && num < 100;
if (isValid){
System.out.println("The given number is valid");
}
else{
System.out.println("The given number is invalid");
}
// ************** TASK GAME CHARACTER
System.out.println("=========================================================");
System.out.println("| Choose Your Class |");
System.out.println("=========================================================");
System.out.println("1. Barbarian: A fierce warrior of primitive background\n" +
" who can enter a battle rage.");
System.out.println("\n2. Bard: An inspiring magician whose power echoes\n" +
" the music of creation.");
System.out.println("\n3. Cleric: A priestly champion who wields divine\n" +
" magic in service of a higher power.");
System.out.println("\n4. Druid: A priest of the Old Faith, wielding the\n" +
" powers of nature and adopting animal forms.");
System.out.println("\n5. Fighter: A master of martial combat, skilled with\n" +
" a variety of weapons and armor.");
System.out.println("\n6. Ranger: A warrior who combats threats on the edges\n" +
" of civilization.");
System.out.println("\n7. Rogue: A scoundrel who uses stealth and trickery\n" +
" to overcome obstacles and enemies.");
System.out.println("\n8. Sorcerer: A spellcaster who draws on inherent magic\n" +
" from a gift or bloodline.");
System.out.println("\n9. Wizard: A scholarly magic-user capable of\n" +" manipulating the structures of reality.\n");
System.out.println("\n\n*** TASK Game Character If Else \n");
int choice = in.nextInt();
/* Remove the block comment above so that the print statements
will instruct the user to select a character.
Print the primary ability based on the choice USING AN IF STATEMENT
Strength: Barbarians and Fighters
Charisma: Bard and Sorcerers
Wisdom: Clerics and Druids
Dexterity: Rangers and Rogues
Intelligence: Wizards
*/
if (choice == 1 || choice == 5){
System.out.println("Your primary ability is Strength.");
}
else if (choice == 2 || choice == 8){
System.out.println("Your primary ability is CHarisma.");
}
else if (choice ==3 || choice == 4){
System.out.println("Your primary ability is Wisdom.");
}
else if (choice == 6 || choice == 7)
{
System.out.println("Your primary ability is Dexterity.");
}
else{
System.out.println("Your primary ability is Intelligence.");
}
}
} //end MishMashEditor is loading...