Sams Teach Yourself Java™ in 24 Hours (Covering Java 7 and Android)

(singke) #1
ptg7068951

154 HOUR 11:Describing What Your Object Is Like


Activities
If all thistalk of viruses didn’t make you sick,you can increase your knowl-
edge of this hour’s topics with the following activity:

. Add a privatevariable to the Virusclass that stores an integer called
newSeconds. Create methods to return the value of newSecondsand
change the value of newSecondsonly if the new value is between 60
and 100.
. Write a Java application that takes an argument as a string,converts it
to a float variable,converts that to a Floatobject,and finally turns
that into an intvariable. Run it a few times with different arguments to
see how the results change.


To s e e J av a p r o g r a m s t h a t i m p l e m e n t t h e s e a c t i v i t i e s ,visit the book’s website
at http://www.java24hours.com.
Free download pdf