home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-08-10 | 2.9 KB | 113 lines |
- package com.ibm.ivj.wte.samples.leapyear;
-
- // Licensed Material - Property of IBM
- // (C) Copyright IBM Corp. 2000 - All Rights Reserved
- //
- // DISCLAIMER:
- // The following [enclosed] code is sample code created by IBM
- // Corporation. This sample code is not part of any standard IBM product
- // and is provided to you solely for the purpose of assisting you in the
- // development of your applications. The code is provided 'AS IS',
- // without warranty or condition of any kind. IBM shall not be liable for any damages
- // arising out of your use of the sample code, even if IBM has been
- // advised of the possibility of such damages.
-
- /**
- * Insert the type's description here.
- * Creation date: (05/22/2000 9:47:20 AM)
- * @author: Administrator
- */
- public class LeapYearBean {
- private static final String copyright =
- "(c) Copyright IBM Corporation 2000.";
-
- private int[] fieldLeapYears = null;
- private int fieldStartYear = 0;
- /**
- * LeapYearBean constructor comment.
- */
- public LeapYearBean() {
- super();
- }
- /**
- * Perform the findLeapYears method.
- */
- public void findLeapYears() {
- // Find next 10 leap years
- final int limit = 10;
- int year=getStartYear();
- setLeapYears(new int[limit]);
- // Find the first leap year
- while (!isLeapYear(year))
- year++;
-
- int i=0;
- while (i<limit) {
- if (isLeapYear(year)) {
- setLeapYears(i, year);
- i++;
- }
- year=year+4;
- }
- return;
- }
- /**
- * Gets the leapYears property (int[]) value.
- * @return The leapYears property value.
- * @see #setLeapYears
- */
- public int[] getLeapYears() {
- return fieldLeapYears;
- }
- /**
- * Gets the leapYears index property (int) value.
- * @return The leapYears property value.
- * @param index The index value into the property array.
- * @see #setLeapYears
- */
- public int getLeapYears(int index) {
- return getLeapYears()[index];
- }
- /**
- * Gets the startYear property (int) value.
- * @return The startYear property value.
- * @see #setStartYear
- */
- public int getStartYear() {
- return fieldStartYear;
- }
- /**
- * Perform the isLeapYear method.
- * @return boolean
- * @param argYear int
- */
- public boolean isLeapYear(int argYear) {
- return (((argYear%4==0) && !(argYear%100==0)) || (argYear%400==0));
- }
- /**
- * Sets the leapYears property (int[]) value.
- * @param leapYears The new value for the property.
- * @see #getLeapYears
- */
- public void setLeapYears(int[] leapYears) {
- fieldLeapYears = leapYears;
- }
- /**
- * Sets the leapYears index property (int[]) value.
- * @param index The index value into the property array.
- * @param leapYears The new value for the property.
- * @see #getLeapYears
- */
- public void setLeapYears(int index, int leapYears) {
- fieldLeapYears[index] = leapYears;
- }
- /**
- * Sets the startYear property (int) value.
- * @param startYear The new value for the property.
- * @see #getStartYear
- */
- public void setStartYear(int startYear) {
- fieldStartYear = startYear;
- }
- }
-