Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this week\'s lab, you should have a minimum of three classes in your applicat

ID: 640470 • Letter: I

Question

In this week's lab, you should have a minimum of three classes in your application:

1. A User Interface class

2. A Calendar Manager class

3. A Calendar Test class

The UserInterface class must allow the user to enter the month, day, and year.

The UserInterface class should also create an instance of the CalendarManager in its constructor and stores it in a member variable.

(1) How would you guys fill out this stub with the *pseudocode* for the UserInterface class required in this week's lab?

public class UserInterface extends JFrame implements ActionListener {

//Declare data member variables/fields for:

public UserInterface() {

}

public void actionPerformed(ActionEvent ev) {

}

}

Pseudocode for the User Interface:

In this week's lab, you should have a minimum of three classes in your application:

1. A User Interface class

2. A Calendar Manager class

3. A Calendar Test class

The UserInterface class must allow the user to enter the month, day, and year.

The UserInterface class should also create an instance of the CalendarManager in its constructor and stores it in a member variable.

(1) How would you guys fill out this stub with the *pseudocode* for the UserInterface class required in this week's lab?

public class UserInterface extends JFrame implements ActionListener {

//Declare data member variables/fields for:

public UserInterface() {

}

public void actionPerformed(ActionEvent ev) {

}

}


Explanation / Answer

A calendar is a system of organizing days for social, religious, commercial, or administrative purposes. This is done by giving names to periods of time , typically days ,weeks,months and years . A date is the designation of a single, specific day within such a system. Periods in a calendar (such as years and months) are usually, though not necessarily, synchronized with the cycle of thee sun or the moon. Many civilizations and societies have devised a calendar, usually derived from other calendars on which they model their systems, suited to their particular needs.

A calendar is also a physical device (often paper). This is the most common usage of the word. Other similar types of calendars can include computerized systems, which can be set to remind the user of upcoming events and appointments.

A calendar can also mean a list of planned events, such as a court calendar.

The English word calendar is derived from the Latin word kalendae, which was the Latin name of the first day of every month.

There is a built in calendar class in java found in the java.util package , under the name calendar.A Calendar object can produce all the calendar field values needed to implement the date-time formatting for a particular language and calendar style (for example, Japanese-Gregorian, Japanese-Traditional). Calendar defines the range of values returned by certain calendar fields, as well as their meaning. For example, the first month of the calendar system has value MONTH == JANUARY for all calendars.

One thing to notice in the calendar class is the difference between roll() and add() .

Calendar.roll()
Changes a specific unit and leaves 'larger' (in terms of time-month is 'larger' than day) units unchanged. The API example is that given a date of August 31, 1999, rolling by (Calendar.MONTH, 8) yields April 30, 1999. That is, the DAY was changed to meet April's maximum, but the 'larger' unit, YEAR, was unchanged.

Calendar.add()
Will cause the next 'larger' unit to change, if necessary. That is, given a date of August 31, 1999, add(Calendar.MONTH, 8) yields April 30, 2000. add() also forces a recalculation of milliseconds and all fields.

Calendar provides internationalization support.

Calendar is a abstract class, and you cannot use the constructor to create an instance. Instead, you use the static method Calendar.getInstance() to instantiate an implementation sub-class.

* Calendar.getInstance(): return a Calendar instance based on the current time in the default time zone with

the default locale.

* Calendar.getInstance(Timezone zone)

* Calendar.getInstance(Locale aLocale)

* Calendar.getInstance(TimeZone zone, Locale aLocale)

Looking into the source code reveals that: getInstance() returns a GregorianCalendar instance for all locales, (except BuddhistCalendar for Thai ("th_TH") and JapaneseImperialCalendar for Japanese ("ja_JP")).

The most important method in Calendar  is get ( int calendarField ), which produces an int . The calendarField are defined as static constant .

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote