java


If my game has three lives, how do I subtract one life if the player gets an answer incorrect?


My game code is linked below. I have a static int at the top (above the main), called lives, it has a total of three. Later in my game, I want to make it so when the player gets a question wrong, it subtracts a life from the int variable. Is it possible that I can do such a thing? I am later going to have a while loop that will recognize when they run out of lives, and end the code. Thanks for the help in advance.
package simon_4_randomgame;
import static java.lang.Thread.sleep;
import java.util.Scanner;
public class Simon_4_RandomGame {
static String username;
static int lives = 3;
public static void main(String[] args) throws InterruptedException {
Scanner name = new Scanner(System.in);
System.out.println("Please enter a username.");
username = name.nextLine();
System.out.println("");
System.out.println("Hello, " + username + ". Welcome to Fault.");
System.out.println("As you make your way through this game you will be");
System.out.println("encountered with a list of faults. In order to win the");
System.out.println("game, you must fix these problems. Good Luck!");
System.out.println("");
sleep(6000);
System.out.println("This game gives you three lives. Answer something incorrect...");
System.out.println("Well. There goes a life. Have fun!");
}
}
I am writing this answer because I am a hungry bastXXd that craves for REPUTATIONS
When the user answered one wrong, do:
lives--;
THERE YOU GO

Related Links

how to create draggable toggle button in Android
Permutation of a 2 dimensional arraylist
Cast a String object to XMLNode object
how to resolve eclipse error Source not found
Can Mirth send JavaBeans on JMS?
How are Java interfaces used? [closed]
Using a external jar. No suitable driver found for jdbc:sqlserver
Java synchronizing a method in a class
Hibernate : refresh on detached object - weird behavior
Java program Not running in Eclipse [duplicate]
Make Graphics from JPanel visible outside JPanel
stdint.h for Java? [duplicate]
Design an Avro schema basis on my JSON document
creation of jtable of this format in java
Java - Synchronized
How to block until thread pool is empty… with an unknown number of threads?

Categories

HOME
java
testng
deezer
onedrive
relay
kalman-filter
jsp-tags
amazon-ecs
electronics
fsm
umd
webpack-2
onelogin
ios-charts
synchronization
basic
quicklook
jsprit
iolanguage
highlight.js
footer
excel-vba-mac
contextmenu
introduction
cx-freeze
excel-2007
realex-payments-api
autosys
java-7
qhull
apache-commons-io
virtualdub
atlassian-crucible
libuv
frame
winrt-xaml-toolkit
calibre
framemaker
android-nestedscrollview
overriding
disassembling
swisscomdev
sharefile
cookiecutter-django
ibpy
keydown
network-flow
revapi
worksheet
blogengine.net
darcs
knockout-components
nodebb
knpmenubundle
iso8601
messenger
probability-density
bonobo
testng-dataprovider
bluemix-app-scan
energy
pervasive-sql
thredds
cannon.js
purge
quicklisp
javax.mail
website-monitoring
qpainter
file-copying
cctv
gulp-less
php-5.4
google-reader
htmlcleaner
valuechangelistener
oracle-warehouse-builder
intentservice
dbconnection
batterylevel
shellexecute
mqx
itmstransporter
coderush
netdna-api
gwt-ext
doh
subgurim-maps
xmlspy
dmx512
filtered-index
preference
vc90
aquaticprime
private-members
msdev
wsdl.exe
misv

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App