One of my favorite movies was Big Hero 6 in which one of the characters was a healthcare robot named Baymax. Using Java, I created a program to emulate Baymax. The program starts with asking the user how they are feeling. If the user responds with something such as "bad", "hurt", or "not feeling well", then the robot Baymax is summoned. Baymax greets the user and then based on user input tries to help. I created a Hurt, Pain. Broken, and Bleeding class which is called within the main class depending on what the user enters.
mport java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class Main {
public static boolean statisfied = false;
public static int pain = 0;
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println("How are you doing today? ");
String answer = s.next();
String[] symptoms = {"bad", "hurt", "not feeling well", "depressed", "anxious", "sick", "stressed", "worried about chem", "Ouch"};
List<String> sym = Arrays.asList(symptoms);
if(sym.contains(answer) || sym.contains(answer.toUpperCase())){
while(!statisfied){
Greeting();
}
}else{
System.out.println("Good to hear, have a nice day!");
}
}
public static void Greeting(){
Scanner scan = new Scanner(System.in);
System.out.println("Hello I am Baymax, your personal heath care companion.");
System.out.println("I was alerted to the need for medical attention.");
Pain p = new Pain();
System.out.println("On a scale of 1-10 how would you rate your pain.");
pain = scan.nextInt();
System.out.println(pain);
Pain.painlevel(pain);
System.out.println("What is your name?");
String name = scan.next();
System.out.println("How can I help, " + name + "?");
String response = scan.next();
if (response.contains("bleeding")){
Bleeding b = new Bleeding();
Bleeding.bandAid();
Bleeding.solved("bleeding");
statisfied();
}else if(response.contains("broken")){
Broken broke = new Broken();
Broken.brokenBone();
Bleeding.solved("pain");
statisfied();
}else if(response.contains("hurt") || response.contains("hurts")){
Hurt.hurts();
Hurt.solved("pain");
statisfied();
}else if(response.contains("stressed") || response.contains("anxious") || response.contains("depressed")){
System.out.println("Take a deep breath, everything will be okay!!");
}else{
System.out.println("Sorry, I don't understand.");
}
}
public static void statisfied(){
Scanner s = new Scanner(System.in);
String stat = s.next();
if(stat.equals("Yes") || stat.equals("yes") || stat.equals("y")){
statisfied = true;
System.out.println("I have been happy to assist you.");
System.out.println("Here's a lollipop for being a good patient.");
System.out.println("Goodbye");
}else{
statisfied = false;
}
}
}
import java.util.Random;
import java.util.Scanner;
public class Hurt extends Bleeding {
public static void hurts(){
System.out.println("What hurts?");
Scanner scan = new Scanner(System.in);
String hurt = scan.next();
System.out.println("Do you need an X-ray for " + hurt);
String respon = scan.next();
if (respon.equals("yes") || respon.equals("Yes")){
System.out.println("Performing X-Ray");
System.out.println("Scanning.....");
Random r= new Random();
int ran = r.nextInt(10) +1;
if(ran == 1 || ran == 4 || ran == 7 || ran == 9){
System.out.println("X-Ray is done");
System.out.println("Bad news");
System.out.println(hurt + " is broken");
}else{
System.out.println("X-ray is done");
System.out.println("Good news!!");
System.out.println(hurt + " is not broken");
System.out.println("Getting cast for " + hurt);
System.out.println("Getting ice for " + hurt);
}
}else{
System.out.println("Here is some ice for your injury");
}
import java.util.Scanner;
public class Broken extends Bleeding{
public static void brokenBone(){
System.out.println("What bone is broken?");
Scanner scan = new Scanner(System.in);
String bone = scan.next();
System.out.println("Preparing a cast for " + bone);
System.out.println("Getting ice for " + bone );
}
}
import org.w3c.dom.ls.LSOutput;
import java.util.Scanner;
public class Bleeding {
private static boolean statisfied;
public static void bandAid(){
System.out.println("Here is a band aid for your injury");
}
public boolean getStatisfied(){
return this.statisfied;
}
public static void solved(String problem){
System.out.println("Did that stop the " + problem + " ?");
Scanner scan = new Scanner(System.in);
String resp = scan.next();
if(resp.equals("Yes") || resp.equals("yes") || resp.equals("y")){
System.out.println("Okay, are you satisfied with your care");
System.out.println("I can not deactivate until you say you've been satisfied by your care");
}else{
System.out.println("I'm sorry, what else can I do to help?");
}
}
}
import org.w3c.dom.ls.LSOutput;
import java.util.Scanner;
public class Pain {
public static void painlevel(int Pain){
Scanner scan = new Scanner(System.in);
int pain = scan.nextInt();
System.out.println("Your pain is " + Integer.toString(pain));
}
}