Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1 ( Composition ) : / / 1 5 / / Preparation: 1 . Create a new NetBeans project called Question 1 . 2

Question 1(Composition): //15//
Preparation:
1. Create a new NetBeans project called Question1.
2. In the extracted provided files, under folder Q1, you will find the files needed for this question.
3. Add the provided Hand.jar file to the Libraries for Question1 project.
4. Remember to Edit the Hand library and add the extracted javadoc" folder as the Javadoc for this library.
5. Create a new class called AnalogueWatch for the Question1 project and complete it as described below.
The questions:
An analog watch, also called an analogue watch, is a timepiece that displays the time using hands on a traditional clock face, as opposed to a digital display
that shows the time in numerals. The analog watch has different parts but the most important are the face and the 3 hands.
The face is the front of the watch, where the hands and markings are located. It is usually made of glass or plastic and can be round, square, or other shapes.
The hands are the pointers that rotate around the face to indicate the time. There are typically three hands:
Hour hand: The shorter hand that points to the hour.
Minute hand: The longer hand that points to the minute.
Second hand: A very thin hand that sweeps around the face once every minute.
For this question, it is expected of you to create a concrete class called AnalogueWatch that represents an analogue watch. Follow the instructions in the
description table (Table 1.2) and the information given in the UML diagram (Table 1.1) and complete the AnalogueWatch class.,
oop.ct2.analoguewatch.AnalogueWatch
faceType: String
faceShape: String
hoursHand: Hand
minuteHand: Hand
secondHand: Hand
+ AnalogueWatch(char, char, Hand, Hand, Hand)
+ AnalogueWatch(char, char, char, char, char, int, int, int)
+ getHoursHand(): Hand
+ getMinuteHand(): Hand
+ getSecondHand(): Hand
handName(Hand): String
faceDetails(char): String
+ showTime(): String
Table 1.1 UML Class Diagram (AnalogueWatch)
3
Member/Method Description Marks
faceType
faceShape
hoursHand
minuteHand
secondHand
These are instance data members of the AnalogueWatch class. As described above, the watch
face type is either glass (G) or plastic (P) and the shape is either round (R), square (S), or
other O).
The watch will have an hour, minute, and second hand.
AnalogueWatch(char, char, Hand, Hand,
Hand)
The parameterized constructor will receive as parameters the characters that represent the
shape and type of the face of the watch. It also receives the 3 Hand objects for the watch.
It must use these parameters to initialize the instance data members.
The constructor will invoke the faceDetails() method (twice) to set the 2 data members
(faceType and faceShape) with the correct values.
AnalogueWatch(char, char, char, char, char,
int, int, int)
The overloaded parameterized constructor will receive as parameters the 2 characters that
represent the shape and type of the face of the watch.
The constructor will invoke the faceDetails() method (twice) to set the 2 data members
(faceType and faceShape) with the correct values.
The next 3 characters and the 3 int parameters are the values that should be used to initialize
the 3 Hand instance data members.
getHoursHand()
getMinuteHand()
getSecondHand()
Mutator methods.
handName(Hand) The facilitator/helper method is used to find the description or name of the hand on the watch.
It will receive a Hand object as a parameter.
If the length attribute of the hand is L then the name is Minute hand.
If the length attribute of the hand is S then the name is Hour hand.
If the length attribute of the hand is T then the name is Second hand.
faceDetails(char) The facilitator/helper method is used to find the description of the face of the watch. It will
receive a char as a parameter.
4
Table 1.1 Class Description (AnalogueWatch)
Submitting your answers:
Following the instructions on EC under section 1 submit your answers for this question.
The watch face type is either Glass(G) or Plastic(P) and the shape is either Round(R),
Square(S), or OtherO).
showTime() This method returns a description of the time that is being displayed on the face of the watch.
The return description will always start with The hands on the watch is as follows: .
Examples of the returning description:
Remember it will only return the String content to display, not the message box.
image text in transcribed

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

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago