Question

public void snooze() – Checks to see if alarm has just sounded (clock time is the...

public void snooze() – Checks to see if alarm has just sounded (clock time is the alarm time and alarm is on). If it has just sounded, the alarm time is reset to be 4 minutes later than current alarm time.

How would I create this public method in Java?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

public class Alarm{

public static void main(String[] args){

Alarm alarm=new Alarm();

Date dateOne = new Date();

Scanner sc=new Scanner(System.in);

private static Long timeStampinmillis=sc.nextLong();

alarm.setAlarm(timeStampinmillis);

}

public void setAlarm(Long timeinmillis){

dateOne.setTime(timeinmillis);

System.out.println("Alarm ringtone rang");

snooze(dateOne.getTime());

}

public void snooze(Long time){

dateOne.setTime(time);

 Date date=new Date(time+5*60*1000);

Timestamp ts=new Timestamp(date.getTime());

timeStampinmillis=timestamp.getTime();

}

}

Add a comment
Know the answer?
Add Answer to:
public void snooze() – Checks to see if alarm has just sounded (clock time is the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • a. Suppose we want to develop software for an alarm clock. The clock shows the time...

    a. Suppose we want to develop software for an alarm clock. The clock shows the time of a day. Using buttons, the user can set the hours and minutes fields individually, and choose between 12 and 24-hour display. It is possible to set one or two alarms. When an alarm is triggered, it will sound some noise. The user can turn it off, or choose to 'snooze'. If the user does not respond at all, the alarm will turn off...

  • JAVA PROGRAM. Write a program to implement a class Clock whose getHours and getMinutes methods return the current time a...

    JAVA PROGRAM. Write a program to implement a class Clock whose getHours and getMinutes methods return the current time at your location. Also include a getTime method that returns a string with the hours and minutes by calling the getHours and getMinutes methods. Provide a subclass WorldClock whose constructor accepts a time offset. For example, if you livein California, a new WorldCLock(3) should show the time in NewYork, three time zones ahead. Include an Alarm feature in the Clock class....

  • Need help with this java code supposed to be a military time clock, but I need...

    Need help with this java code supposed to be a military time clock, but I need help creating the driver to test and run the clock. I also need help making the clock dynamic. public class Clock { private int hr; //store hours private int min; //store minutes private int sec; //store seconds public Clock () { setTime (0, 0, 0); } public Clock (int hours, intminutes, int seconds) { setTime (hours, minutes, seconds); } public void setTime (int hours,int...

  • Feedback See Hint Before bed, many students set their alarm, intending to get up early. When...

    Feedback See Hint Before bed, many students set their alarm, intending to get up early. When the buzzer goes off in the morning, however, many students lean over and hit the snooze button for an extra 5 minutes of sleep. Rationally speaking, if extra sleep time is available, the person should just set his or her alarm for later in the morning This irrational behavior is best explained by Choose one: A. intertemporal decision-making. B. priming effects. C. framing effects....

  • Please help with Java programming! This code is to implement a Clock class. Use my beginning...

    Please help with Java programming! This code is to implement a Clock class. Use my beginning code below to test your implementation. public class Clock { // Declare your fields here /** * The constructor builds a Clock object and sets time to 00:00 * and the alarm to 00:00, also. * */ public Clock() { setHr(0); setMin(0); setAlarmHr(0); setAlarmMin(0); } /** * setHr() will validate and set the value of the hr field * for the clock. * *...

  • Problem 1.(1) Implement a class Clock whose getHours and getMinutes methods return the current time at...

    Problem 1.(1) Implement a class Clock whose getHours and getMinutes methods return the current time at your location. (Call java.time.LocalTime.now().toString() or, if you are not using Java 8, new java.util.Date().toString() and extract the time from that string.) Also provide a getTime method that returns a string with the hours and minutes by calling the getHours and getMinutesmethods. (2) Provide a subclass WorldClock whose constructor accepts a time offset. For example, if you live in California, a new WorldClock(3) should show...

  • Can you please pick Automobile For this assignment. Java Programming Second Inheritance OOP assignment Outcome: Student...

    Can you please pick Automobile For this assignment. Java Programming Second Inheritance OOP assignment Outcome: Student will demonstrate the ability to use inheritance in Java programs. Program Specifications: Programming assignment: Classes and Inheritance You are to pick your own theme for a new Parent class. You can pick from one of the following: Person Automobile Animal Based on your choice: If you choose Person, you will create a subclass of Person called Student. If you choose Automobile, you will create...

  • For this project you will be writing up a simple Clock program to keep track of...

    For this project you will be writing up a simple Clock program to keep track of time. SimpleClock.java - contains your implementation of the SimpleClock class. You will need to provide the code for a constructor as well as the mutator methods set and tick and the accessor method toString. Look at the comments for each method to see how they should be implemented - the trickiest method is probably tick, which requires that you deal with the changing of...

  • in java if i had a method lets say called... public void Method(Object c) how would...

    in java if i had a method lets say called... public void Method(Object c) how would i make it throw an exception if it is called too many times... more times than my final attribute MAX

  • This is a Java programming assignment and I want help with the Time class. See below...

    This is a Java programming assignment and I want help with the Time class. See below for assignment details: For this question you must write a java class called Time and a client class called TimeClient. The partial Time class is given below. (For this assignment, you will have to submit 2 .java files: one for the Time class and the other one for the TimeClient class and 2 .class files associated with these .java files. So in total you...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT