Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Date /* A simple Date class Anderson, Franceschi */ public class Date { private int month; private int day; private int year; /** default constructor

image text in transcribedimage text in transcribed

Date

/* A simple Date class Anderson, Franceschi */

public class Date { private int month; private int day; private int year;

/** default constructor * sets month to 1, day to 1 and year to 2000 */ public Date( ) { setDate( 1, 1, 2000 ); }

/** overloaded constructor * @param mm initial value for month * @param dd initial value for day * @param yyyy initial value for year * * passes parameters to setDate method */ public Date( int mm, int dd, int yyyy ) { setDate( mm, dd, yyyy ); }

/* accessor methods */ int getMonth( ) { return month; } int getDay( ) { return day; } int getYear( ) { return year; }

/** mutator method */ /** setMonth * @param mm new value for month * if mm is between 1 and 12, sets month to mm * otherwise, sets month to 1 */ public void setMonth( int mm ) { month = ( mm >= 1 && mm

/** setDay * @param dd new value for day * if dd is legal day for current month, sets day to dd * otherwise, sets day to 1 */ public void setDay( int dd ) { int [] validDays = { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; day = ( dd >= 1 && dd

/** setYear * @param yyyy new value for year * sets year to yyyy */ public void setYear( int yyyy ) {

DateClient1

public class DateClient1 { public static void main( String [] args ) { // add code to construct Data objects // and test and output if they are a // leap year or not // not leap year (not divisible by 4) // leap year (divisible by 4, but not by 100) // not leap year (divisible by 4 and by 100) // leap year (divisible by 4 and by 100 and by 400) // your birth year } }

3)14pt] We are going to upgrade the the user defined Date class from Lab 3. To get started download Date.java and DateClientl java and put them in the same directory You will modify these files to do the following Leap Year: o add and test using DateClientl.java a new boolean method leapYearO that returns true or false depending if the Date year is a leap year or not. See below for rules to determine if a year is a leap year: Every year divisible by 4 is a leap year. o But every year divisible by 100 is NOT a leap year. o Unless the year is also divisible by 400, then it is still a leap year. Code then test (complete and check against Expected Result below) your method by updating DateClientl java by adding the code requested. . Chinese Calendar: The Chinese calendar associates animals with cach year in a twelve year cycle. 1900 was the "Year of the Rat" and the following years were assigned the following animals in this order Ox, Tiger, Rabbit, Dragon, Snake, Horse, Ram, Monkey, Rooster, Dog, and Boar. Then 1912 is "Year of the Rat" again, and so orn. . add a new method animal Year0 that returns a String (in the format "Year of the ") corresponding to the Chinese calendar animal as defined above Tasks: Write pseudocode for solving the above problems. Step through your pseudocode to be sure that it works Implement your pseudocode in java. Be sure your program is appropriately Complete the test plans below. . documented. Accept user input from the keyboard Compile and run your program to see if it runs (no run-time errors) Test your program with the test plans below, If you discover mistakes in your program, correct them and execute the test plan agairn

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Creating A Database In Filemaker Pro Visual QuickProject Guide

Authors: Steven A. Schwartz

1st Edition

0321321219, 978-0321321213

More Books

Students also viewed these Databases questions