Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

If statement problem

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

basically the timer i have coded reads the current time and checks to see whether it is that specific time if yes display on if no display no, it doesnt like the statement i have created.

if (timerhour24 == hourOn < hourOff && timermin == minOn < minOff)

 
Marshal
Posts: 26912
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sean beacham wrote:however the gregorian calender doesnt constantly update and is static to the time you have opened it up how can i fix this??



Just create a new one whenever you need to get the current time.
 
Paul Clapham
Marshal
Posts: 26912
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sean beacham wrote:it also doesnt like this statement

if (timerhour24 == hourOn < hourOff && timermin == minOn < minOff)



Well, that's because it isn't valid Java syntax (which you already knew because you got a compiler error). However I don't have any suggestions about how to fix it, because I can't tell what it was supposed to mean. Could you explain it in words?
 
sean beacham
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:

sean beacham wrote:it also doesnt like this statement

if (timerhour24 == hourOn < hourOff && timermin == minOn < minOff)



Well, that's because it isn't valid Java syntax (which you already knew because you got a compiler error). However I don't have any suggestions about how to fix it, because I can't tell what it was supposed to mean. Could you explain it in words?



ok what i have is 2 jcomboboxes 1 is switch ontime(hourOn,minOn) and the other is switch offtime(hourOff,minOff)
the statement basically says do statement from start time until the end time
 
Paul Clapham
Marshal
Posts: 26912
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That isn't at all helpful. You posted an if-statement, but now you're saying it says "do from start time to end time"? That doesn't make any sense at all, because you can't do that with an if-statement.

Not to mention that your if-statement refers to variables named timerhour24 and timermin, but your explanation doesn't refer to those variables in any way.

Let's try again. Your if-statement was meant to compare two values. Or maybe four values, I don't know. Can you explain what those values are, what they mean, and how you meant to compare them?
 
sean beacham
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:That isn't at all helpful. You posted an if-statement, but now you're saying it says "do from start time to end time"? That doesn't make any sense at all, because you can't do that with an if-statement.

Not to mention that your if-statement refers to variables named timerhour24 and timermin, but your explanation doesn't refer to those variables in any way.

Let's try again. Your if-statement was meant to compare two values. Or maybe four values, I don't know. Can you explain what those values are, what they mean, and how you meant to compare them?



not to worry i think ive confused yourself and myself

i rewrote it like this

 
Paul Clapham
Marshal
Posts: 26912
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, that looks more reasonable. I could complain about your choice of having both a variable and a method named "boilerstatus" -- that could be confusing -- and about the fact that the Timer runs forever and it looks like it's possible to create any number of those Timers by clicking the button more than once. But it's a good first draft.
 
reply
    Bookmark Topic Watch Topic
  • New Topic