1. Check out the Store if you're looking to Buy HL2RP or other schemas for your server. You can click Buy Schemas on the very top navigation bar to visit the store.
  2. Use the Plugin Center to easily subscribe to and auto-install Clockwork plugins to your server, or submit and share plugins you have developed.
  3. Having trouble setting up or developing with Clockwork? Check out the Wiki or post in the Support Forum for advice from fellow users.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

[JAVA]Can't figure out why this is returning true.

Discussion in 'Help' started by GreenVorpal, Mar 26, 2014.

  1. GreenVorpal

    GreenVorpal Not actually green Active Member

    When I use.
    Month = 4
    Day = 26
    Year = 1997

    It returns true, and I can't seem to figure out why.

    this.getLeap() refers to whether or not it is a leap year, and can be ignored.
     
  2. Tommy

    Tommy Guest

    Code:
    public boolean IsError(){
    		boolean e;
    		e = false;
    		if (day <= 0)
    			e = true;
    		if ((month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10) && day >= 32)
    			e = true;
    		if ((month == 4 || month == 6 || month == 9 || month == 11) && day >= 31)
    			e = true;
    		if (month == 2 && this.getLeap() == true && day >= 30)
    			e = true;
    		if (month == 2 && this.getLeap() == false && day >= 29)
    			e = true;
    		if (year <= 0)
    			e = true;
    		if (month >= 13 || month <= 0)
    			e = true;
    		return e;
    
    There's java code tags.

    As for the code, your final if condition.

    Code:
                    if (month >= 13 || month <= 0)
                            e = true;
    
    At least, I believe so. I don't know java, just assuming || is equivalent to an "or".
     
  3. GreenVorpal

    GreenVorpal Not actually green Active Member

    Thanks, I actually just figured it out... I was being stupid and not setting date, month, and year in my server class, before checking to see if there was an error. Seeing as they all were defaulted to zero, naturally it was returning an error.
     

Previous Readers (Total: 0)