• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

working with seconds from midnight

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So currently I coded a program where it displays seconds from midnight. However, I did this wrong and instead of doing

I'm only supposed to use private int secondsFromMidnight and then implement every constructor and every method in Time2 in terms of secondsFromMidnight, not hours minutes, and seconds. Though there will still be parameters called hours, minutes, and seconds. Just the instance variable will be secondsFromMidnight. I'm having trouble changing from the 3 int into just 1 int called secondsfromMidnight. This is my code so far (note: I've excluded the test class)


Any suggestions or help is appreciated, thank you
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apart from the fact that is shou‍ld read hour minute second not Hour Minute Second, I think you have gone so far from the original requirements that you will have to start from scratch. Start by writing on paper how you are going to calculate hours minutes and seconds from seconds since midnight. It is not that difficult. Remind yourself of the different arithmetic operators in the Java™ Tutorials. Ignore what it says about unary +.
 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic