Tuesday, October 18, 2011

CHALLENGE:Java Tut 36-37-Display Reg Time

The following is a challenge for new developers that have completed:
 Java Tutorial - 36-37 Displaying Regular Time by theNewBoston
 To get the most out of these challenges try them a few hours or the day after watching/following along with the actual video.
 

CHALLENGE!!
(Before starting any of the challenges always declare a class and a main method unless told otherwise)
 Difficulty:
 
1.Create a class and name it "Time".Unlike classes we've created in the past you dont need to declare a main method.

2.Create 3 int vars. name them hour, minute, second.

3.Create a method,name it setTime, it should accept 3 parameters(int h, int m , int s)
Inside the setTime method:
  • if h is greater than 0 and less than 24 then set h to hour, else set the hour to 0 by default.This should be accomplished in one line of code( Hint:use the "ternary operator" instead of a if statement)
  • if m is greater than 0 and less than 60 then set m to minute, else set the minute to 0 by default.(Hint: "ternary operator")
  • if s is greater than 0 and less than 60 then set s to second, else set the second to 0 by default.(Hint: "ternary operator")
End "setTime" method 

4.Create another method.Name it toMilitary.
Inside the to Military method:
  • Create a return statement that will format the "hour" , "minute" and "second" vars to display in military format.
    Example of console output:18:30:00
    End "toMilitary" method
5.Create a method,name it toRegTime
Inside the "toRegTime" method:
  • Create a return statement that will format the "hour" , "minute" and "second" vars to display in standard time format. (hint:Ull need to use the Modulus (%) operator
    Example of console output:6:30:00 PM
End "toRegTime" method

End of "Time" class

6.Create another class and name it testTime .Create a main method.

Inside the main method of testTime class:
  • Declare a new Time object and name it tickTock.
  • Print tickTock.toMilitary
  • Print tickTock.toRegTime
  • Call the setTime method with the parameters (13,27,6)
  • Print tickTock.toMilitary
  • Print tickTock.toRegTime
End of "testTime" class
COMPILE & PRAY TO DUKE!!!
View the video tutorial: http://bit.ly/qkxfja 

12 comments:

Unknown said...

Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
Advanced AWS Training in Bangalore | Best Amazon Web Services Training Institute in Bangalore
Advanced AWS Training Institute in Pune | Best Amazon Web Services Training Institute in Pune
Advanced AWS Online Training Institute in india | Best Online AWS Certification Course in india
AWS training in bangalore | Best aws training in bangalore

jeeva said...

Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
microsoft azure training in bangalore
rpa training in bangalore
rpa training in pune
best rpa training in bangalore

rohini said...

Thanks for your informative article, Your post helped me to understand the future and career prospects & Keep on updating your blog with such awesome article.
Best Devops training in sholinganallur
Devops training in velachery
Devops training in annanagar
Devops training in tambaram

gowsalya said...

Great thoughts you got there, believe I may possibly try just some of it throughout my daily life.
python Course in Pune
python Course institute in Chennai
python Training institute in Bangalore

htop said...

thank you so much for sharing this information,its useful to us
data Science training in chennai
best devops training in chennai
 devops training in chennai
best hadoop training in chennai
best hadoop training in omr
hadoop training in sholinganallur
best java training in chennai

ramya said...

Thanks for your post very userful for the readers .keep me as a bookmark for future reference .
Rpa training in chennai | RPA training course chennai
AI training in chennai




Rashika said...

Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
AWS training in chennai | AWS training in annanagar | AWS training in omr | AWS training in porur | AWS training in tambaram | AWS training in velachery

praveen said...

Hi,Great information.Thanks for sharing.I always read your blog and get lot of useful information.
web designing training in chennai

web designing training in porur

digital marketing training in chennai

digital marketing training in porur

rpa training in chennai

rpa training in porur

tally training in chennai

tally training in porur

Jayalakshmi said...

Hi,Great information.Thanks for sharing.I always read your blog and get lot of useful information.
web designing training in chennai

web designing training in tambaram

digital marketing training in chennai

digital marketing training in tambaram

rpa training in chennai

rpa training in tambaram

tally training in chennai

tally training in tambaram

jeni said...

Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites!
oracle training in chennai

oracle training in velachery

oracle dba training in chennai

oracle dba training in velachery

ccna training in chennai

ccna training in velachery

seo training in chennai

seo training in velachery

shiny said...

After reading this web site I am very satisfied simply because this site is providing comprehensive knowledge for you to audience





java training in chennai

java training in annanagar

aws training in chennai

aws training in annanagar

python training in chennai

python training in annanagar

selenium training in chennai

selenium training in annanagar

deiva said...

Hi,Great information.Thanks for sharing.I always read your blog and get lot of useful information.
oracle training in chennai

oracle training in omr

oracle dba training in chennai

oracle dba training in omr

ccna training in chennai

ccna training in omr

seo training in chennai

seo training in omr




Post a Comment

 
;