7 Replies - 1984 Views - Last Post: 21 December 2013 - 06:56 AM Rate Topic: -----

#1 Morooj  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 28
  • Joined: 18-December 13

can you help to explain this cod what dose it mean and what it do ?

Posted 19 December 2013 - 10:49 AM

private int checkDay( int testDay )
     {
      int daysperMonth [] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
       // check if day in rang for month 
      if (testDay >0 && testDay <= daysperMonth[month])
         return testDay ;
         // check for leap year
      if (month ==2 && testDay ==24 &&(year %400 ==0 || (year %4 ==0 && year %100!=0) ) )
         return testDay ;
         System.out.printf ("Invalid day (%d) set to 1 ", testDay);
         return 1 ; // maintain object n consistent state
     } // end method checkDay


Is This A Good Question/Topic? 0
  • +

Replies To: can you help to explain this cod what dose it mean and what it do ?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8954
  • View blog
  • Posts: 33,568
  • Joined: 12-June 08

Re: can you help to explain this cod what dose it mean and what it do ?

Posted 19 December 2013 - 10:52 AM

Is this really objectiveC?


That code you jacked is pretty straight forward and actually has comments. What part do you not get?
.
Was This Post Helpful? 0
  • +
  • -

#3 Morooj  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 28
  • Joined: 18-December 13

Re: can you help to explain this cod what dose it mean and what it do ?

Posted 19 December 2013 - 10:58 AM

View Postmodi123_1, on 19 December 2013 - 10:52 AM, said:

Is this really objectiveC?


That code you jacked is pretty straight forward and actually has comments. What part do you not get?
.


if (month ==2 && testDay ==29 &&(year %400 ==0 || (year %4 ==0 && year %100!=0) ) )
return testDay ; this part
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8954
  • View blog
  • Posts: 33,568
  • Joined: 12-June 08

Re: can you help to explain this cod what dose it mean and what it do ?

Posted 19 December 2013 - 10:59 AM

Again - is this java or objectivec?


Read that line out loud.

if the value of variable 'month' equals 2 and also the value of variable 'testday equals 29... etc
Was This Post Helpful? 0
  • +
  • -

#5 Morooj  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 28
  • Joined: 18-December 13

Re: can you help to explain this cod what dose it mean and what it do ?

Posted 21 December 2013 - 06:34 AM

View Postmodi123_1, on 19 December 2013 - 10:59 AM, said:

Again - is this java or objectivec?


Read that line out loud.

if the value of variable 'month' equals 2 and also the value of variable 'testday equals 29... etc

it's java cod
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3243
  • View blog
  • Posts: 10,882
  • Joined: 12-December 12

Re: can you help to explain this cod what dose it mean and what it do ?

Posted 21 December 2013 - 06:39 AM

The word is code not cod.
Was This Post Helpful? 0
  • +
  • -

#7 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3243
  • View blog
  • Posts: 10,882
  • Joined: 12-December 12

Re: can you help to explain this cod what dose it mean and what it do ?

Posted 21 December 2013 - 06:47 AM

         // check for leap year
      if (month ==2 && testDay ==24 &&(year %400 ==0 || (year %4 ==0 && year %100!=0) ) )
         return testDay ;

The comment tells you that it is checking for a leap year. If it is, and the date is 29th, then it returns the date, meaning that it is correct. Otherwise, it prints the following error message.

However, you subsequently corrected the code to use 29 rather than 24. Please always just copy and paste original code in your posts - please do not attempt to retype it.

This post has been edited by andrewsw: 21 December 2013 - 06:48 AM

Was This Post Helpful? 0
  • +
  • -

#8 Morooj  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 28
  • Joined: 18-December 13

Re: can you help to explain this cod what dose it mean and what it do ?

Posted 21 December 2013 - 06:56 AM

View Postandrewsw, on 21 December 2013 - 06:47 AM, said:

         // check for leap year
      if (month ==2 && testDay ==24 &&(year %400 ==0 || (year %4 ==0 && year %100!=0) ) )
         return testDay ;

The comment tells you that it is checking for a leap year. If it is, and the date is 29th, then it returns the date, meaning that it is correct. Otherwise, it prints the following error message.

However, you subsequently corrected the code to use 29 rather than 24. Please always just copy and paste original code in your posts - please do not attempt to retype it.

so that's what it do .... thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1