Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Program- Kitchen Timer

This assignment goes a little beyond simply modifying an existing Bluej project. While there is considerable similarity to the ClockDisplay example we have been working with, there are some distinct differences. While you will no doubt find much of the code from ClockDisplay and NumberDisplay informative, your code here will be different.

The goal is a simple Kitchen Timer. There are only two things a user can do to a timer:

1. Set it, given a number of minutes and seconds.
2. Start it, after which the timer will begin counting down.

Once the timer is started, it will display the time, which will count down each second that passes.

Flashing Finish: When the time expires, the clock display will alternate between "DONE!" and "00:00", changing each second, for a total of 10 seconds. After that, the display should return to "--:--" and your program should stop running.

DisplayWindow Class Provided

First, you may use the DisplayWindow class from the better-clock project. When a new DisplayWindow object is created, a window appears that can display a string of up to nine characters. The default display is "--:--". A method named "setText" is provided to change the string being displayed.

Part I: KitchenTimer Class

You will develop a class named "KitchenTimer". This is the first class you will be developing from scratch. The class will have two fields, one to track the minutes remaining and another to track the seconds remaining. Note that you may use (and modify) the NumberDisplay class from the better-clock project, but you are not required to. The alternative is to simply use integer fields. The choice is up to you. In addition to those two fields, you need to include a field of type DisplayWindow such as:

private DisplayWindow display;

The class will also have the following public interface:

1. A constructor with no parameters. The constructor should initialize both the minutes and seconds remaining to zero and it will create a new TimerDisplay object. If you used the field declaration above, the following line accomplishes this:

display = new DisplayWindow();

2. A method named "setTimer" that includes two integer parameters. This method should set the minutes remaining and the seconds remaining to the values passed as parameters. The method should also build a string to represent the new time and display that new time.

3. A method named "startTimer" that has no parameters. When this method is called, the timer should begin to count down, and should not stop until the time has expired. Then the text "DONE!" should be displayed, flashing on and off as described above. For each second that the clock counts down, your code will need to do the following:

a) Pause for approximately one second. You may use my "wait_a_litttle" method from the ClockDisplay class for this. Just include it as a private static method in your KitchenTimer class.

b) Decrement the time remaining. Note that you will have to handle the rollover of seconds, and unlike when incrementing, your code will need to make a decision to handle this correctly.

c) Build a string to represent the new time.

d) Display that string.

Don't forget to include code to display "DONE!" when time has expired.

IMPORTANT Notes and Advice

• No output from this program will go to the terminal window. Use the DisplayWindow object to display both the time and the string "DONE!".

• As always, start early!

Part II: Sports Clock

If you have ever been to a sporting event at a modern facility, you've probably noticed that when the time remaining is under one minute, the display no longer shows minutes and seconds, but rather minutes and tenths of seconds, and the clock counts down in tenths of seconds during that final minute. The format of the time also changes from mm:ss (example: "12:45") to ss.t, (example: "23.4").

Modify your program to make this happen on your timer. Try not to over-think this. It is probably useful to think of making the clock countdown a two-step process: 1) Count down until there is just one minute left, then 2) Count down the final seconds. Step 2 doesn't need to happen until step 1 is complete, and each of these steps can be handled in their own loop.

Extra Credit!

In the Resources area on Isidore, you will find a file named "ScrollingDone.mp4". If you download that file and double-click on it, you should see a video of a DisplayWindow object that provides an animated display of the string "--DONE!--" that scrolls into the window a total of 11 times, stopping the last time in the middle. For 6 bonus points, make your Kitchen timer end this way, instead of the flashing "DONE!" described above.

Attachment:- Display_Window.rar

Java, Programming

  • Category:- Java
  • Reference No.:- M92054030

Have any Question?


Related Questions in Java

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As