Develop a class named kitchentimer

Assignment Help JAVA Programming
Reference no: EM131299382

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

Reference no: EM131299382

Questions Cloud

Identify how would you describe your communication style : How would you describe your communication style? Describe a situation in which effective interpersonal communication skills contributed to your success.
Write an business report about an aspect of the company : Develop a research question to answer about the company that combines your discipline/concentration with strategic management.
Firm profit-maximizing level of output : The firm estimates the probability of the new regulation being enforced is 0.5. Find the firm's profit-maximizing level of output. Round your answer to one decimal.
Does this study really provide anonymity or just confidental : They can learn the results of the test by telephone, still without giving their name. Does this practice offer anonymity or confidentiality?
Develop a class named kitchentimer : 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.
Define a buffer and explain how a buffer works : On the basis of your research, respond to the following: Define a buffer and explain how a buffer works. Analyze and explain the buffer system in buffered aspirin (carboxylic acid)
Provide an overview of new web-based organization plans : Provide an overview of the new Web-based or Internet network the organization plans to implement. Prepare an overview of the security requirements for the network.
Would revealing the sponsor to respondents bias the poll : The standards accepted by polling organizations also require giving respondents the name and address of the organization that carries out the poll. Why do you think this is required?
Describe understanding of us public health system : In an opening paragraph describe your understanding of U.S. public health system using course material - In a second paragraph discuss how two of the module activities address different aspects of the three core functions of public health (assessme..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a program that uses a dynamic list of strings

Write a program that uses a dynamic list of strings to keep track of a list of chores that you have to accomplish today.

  Java gui program to calculate monthly payment

Java GUI program to calculate monthly payment. The GUI has JTextFields and JButton

  Write a java program to calculate the ideal weight

Write a java program to calculate the ideal weight when you enter the age and height of user

  Set of management functions

Suppose a system uses ACLs to maintain its protection matrix. Write a set of management functions to manage the ACLs when (1) a new object is created; (2) an object is deleted;

  Java program that iterates through the integers

Write a Java program that iterates through the integers from 1 to 20, computing the square of each number and writing the information to a file called squares.txt.

  Create a class that uses the genetricstack class

Create a new class named GenericStack that specifies a type variable that gives for generics - Use the peek method to return the first item and show that item, and use the size method to return the number of items again and show that value.

  Design programs that communicate with web servers

Design programs that communicate with Web servers and server-side applications through the Hypertext Transfer Protocol (HTTP). Design Java programs that use the Structured Query Language to query and update relational databases. Describe the Java Ser..

  Create an artificial life environment

Create an artificial life environment. You should have at least three types of agents: Herbivore, Carnivore, Plant

  Write a declaration for three classes using the inheritance

Write a declaration for all three classes using the principles of inheritence. Make the Building class abstract

  Algorithm analysis with advanced data structures

Write a program to help the merchants devise a sequence of transmutations that would change silver into gold with the smallest possible total fee paid to the alchemists.

  Discussion htmlcssjavascript placementnbspplease respond to

discussion htmlcssjavascript placementnbspplease respond to the followingcompare and contrast the process of adding

  Modify the homestead furniture store application

Design an application for the homestead furniture store that gets sales transaction data including an account number customer name and purchase price.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd