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

Android - Selecting / highlighting a drawn path in canvas
Map the values of array elements
How can I add Normal Java project capabilities to EJB project in Eclipse (.ear)?
Ozeki SMPP KeepAlive error in java
How to add button dynamically in panel?
ORIGINAL EXCEPTION: ReferenceError: io is not defined
Sqlite problems: database file is locked
How to get the Swing MetaWidget to adjust its size dynamically
opening a frame by clicking on the button
RestTemplate Java Spring, no suitable HttpMessageConverter and 422 UnprocessableEntity
Conversation ID leads to unkown path in graph-api
How to run a query in JDBC [duplicate]
java.lang.VerifyError: org/bouncycastle/asn1/x500/X500Name
Spark sql (1.4) : Get current timestamp
Spring Confit issue: Mapping View to Controller Error (NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config) [duplicate]
How to make the method isEmpty() true so that I can end up reading data from InputStream?

Categories

HOME
arduino-uno
fluentd
ngrx
heroku
iterator
bpmn
elm
cmd
google-translate
rascal
postgres-xl
jplayer
fallback
iron-router
iolanguage
saxon
sms-gateway
emulator
mustache.php
captiveportal
claims-based-identity
bootstrap-duallistbox
applozic
replaceall
vision
delicious-api
tinymce-4
fabric8
media-queries
.net-4.0
noraui
mapbox-gl
bower-install
restlet
unobtrusive-validation
galen
g-code
powershell-dsc
http-live-streaming
password-encryption
sas-jmp
executenonquery
logfiles
angular-resource
fault
filepicker
upstart
jquery-nestable
pnotify
veracode
git-diff
recursive-datastructures
elgg
forever
knockout-components
kbuild
google-perftools
python-cryptography
titanium-android
word-vba-mac
log4c
phishing
paypal-express
nsviewcontroller
yaws
livequery
pagerank
php-parse-error
ios8-today-widget
r-tree
jms2
t4mvc
jmeter-maven-plugin
dukescript
drawbitmap
vstest.console.exe
device-orientation
website-monitoring
google-style-guide
javafx-webengine
codeigniter-routing
tld
braille
picturefill
didselectrowatindexpath
srs
prettify
gridfs
yui-compressor
libstdc++
removeclass
stage
qt-jambi
data-loss
servicehost
calling-convention
mysql-error-1005
site.master
paster
wise
castle-monorail
rescale
webkit.net
zune
paul-graham

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