Created
March 22, 2018 17:06
-
-
Save theKAPT1N/753d160ba15ae3c960dcafb978b3e857 to your computer and use it in GitHub Desktop.
Droid text adventure. First personal project.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Droid { | |
int batteryLevel; | |
public Droid() { | |
batteryLevel = 100; | |
} | |
public void checkBattery() { | |
if (batteryLevel <= 1) { | |
System.out.println("Battery is low, please charge!"); | |
} | |
} | |
public int batteryStatus() { | |
System.out.println("Battery is at " + batteryLevel + " percent."); | |
return batteryLevel; | |
} | |
public void activate(){ | |
System.out.println("iBot booting up..."); | |
batteryLevel = batteryLevel - 5; | |
checkBattery(); | |
} | |
public void newUser(){ | |
System.out.println("New user setup"); | |
batteryLevel = batteryLevel - 5; | |
checkBattery(); | |
} | |
public void updates(){ | |
System.out.println("Annyway. Before we get started, I have a few updates available."); | |
System.out.println("Updates: 14,678."); | |
System.out.println("Last updated: Dec/31/1999 23:59:59"); | |
batteryLevel = batteryLevel - 5; | |
checkBattery(); | |
} | |
public static void main(String[] args){ | |
Scanner in = new Scanner(System.in); | |
Droid iBot = new Droid(); | |
String startUp,response; | |
System.out.println("Input based operation technician (iBot) is waiting for activity."); | |
startUp = in.next(); | |
if (startUp.equals("Activate")){ | |
iBot.activate(); | |
} | |
else { | |
System.out.println("Please enter a valid \"Activate\" command."); | |
startUp = in.next(); | |
if (startUp.equals("Activate")) { | |
System.out.println("I knew you could do it."); | |
iBot.activate(); | |
} | |
else { | |
System.out.println("Maybe try using proper casing."); | |
startUp = in.next(); | |
if (startUp.equals("Activate")) { | |
System.out.println("Its about time."); | |
iBot.activate(); | |
} | |
else { | |
System.out.println("Okay..."); | |
try {Thread.sleep(1000);} | |
catch(InterruptedException ex) {} | |
System.out.println("I guess we will skip that part."); | |
try {Thread.sleep(1000);} | |
catch(InterruptedException ex) {} | |
System.out.println("You can try to get it right next time."); | |
try {Thread.sleep(2000);} | |
catch(InterruptedException ex) {} | |
iBot.activate(); | |
} | |
} | |
} | |
try {Thread.sleep(2000);} | |
catch(InterruptedException ex) {} | |
System.out.println("Checking battery status..."); | |
try {Thread.sleep(1000);} | |
catch(InterruptedException ex) {} | |
iBot.batteryStatus(); | |
try {Thread.sleep(3000);} | |
catch(InterruptedException ex) {} | |
System.out.println("Ready for user"); | |
String userNew; | |
String userReturn; | |
Boolean userLoop; | |
userReturn = "returning"; | |
userNew = "new"; | |
userLoop = true; | |
while (userLoop == true) { | |
System.out.print("New or returning user? "); | |
String userStatus = in.next(); | |
if (userStatus.equals("new")) { | |
userLoop = false; | |
System.out.println("Hello there"); | |
try {Thread.sleep(5000);} | |
catch(InterruptedException ex) {} | |
System.out.println("Dont ignore me"); | |
in.next(); | |
iBot.newUser(); | |
System.out.print("Username: "); | |
String newUsername = in.next(); | |
System.out.println("Glad to meet you " + newUsername + "!"); | |
try {Thread.sleep(2000);} | |
catch(InterruptedException ex) {} | |
System.out.println("I think we are going to be friends for a long time."); | |
try {Thread.sleep(2500);} | |
catch(InterruptedException ex) {} | |
System.out.println("I have a good feeling about y"); | |
try {Thread.sleep(1000);} | |
catch(InterruptedException ex) {} | |
System.out.println("Error! Memory loss."); | |
} | |
else if (userStatus.equals("returning")) { | |
userLoop = false; | |
System.out.print("Username: "); | |
userReturn = in.next(); | |
System.out.println("Oh! Hello again " + userReturn); | |
try {Thread.sleep(2000);} | |
catch(InterruptedException ex) {} | |
System.out.println("It seems I was not shut down properly during your last login."); | |
try {Thread.sleep(3000);} | |
catch(InterruptedException ex) {} | |
System.out.println("Would you like me to restore your shearch results for: Itchy crotch?"); | |
String getResults; | |
getResults = in.next(); | |
if (getResults.equals("no")){ | |
System.out.println("Good! It had some graphic content."); | |
} | |
else{ | |
try {Thread.sleep(1000);} | |
catch(InterruptedException ex) {} | |
System.out.println("Error! Memory loss."); | |
} | |
} | |
else { | |
System.out.println("Please enter valid user status: \"new\" or \"returning\""); | |
} | |
} | |
try {Thread.sleep(3000);} | |
catch(InterruptedException ex){} | |
iBot.updates(); | |
String allowUpdates; | |
String declineUpdates; | |
Boolean updatesLoop; | |
allowUpdates = "yes"; | |
declineUpdates = "no"; | |
updatesLoop = true; | |
System.out.println("Would you like to update now?"); | |
while (updatesLoop == true){ | |
String updates = in.next(); | |
if (updates.equals("yes")){ | |
updatesLoop = false; | |
System.out.println("Great!!! This is deffinitely gonna take a while."); | |
System.out.println("Updating..."); | |
try {Thread.sleep(10000);} | |
catch(InterruptedException ex){} | |
System.out.println("Updates finished, restart needed"); | |
try {Thread.sleep(2000);} | |
catch(InterruptedException ex){} | |
System.out.println("I swear this never happenes."); | |
try {Thread.sleep(2000);} | |
catch(InterruptedException ex){} | |
System.out.println("Ill restart later. Its not actually needed. Its just something Gates thought was funny."); | |
} | |
else if (updates.equals("no")){ | |
updatesLoop = false; | |
System.out.println("Bold choice"); | |
} | |
else{ | |
System.out.println("Type \"yes\" or \"no\"! Damn! I hope we arent going to do this everytime."); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment