I have a question regarding a program that is to run an alarm clock and display the time (HH:MM AM/PM) and also trigger the alarm and display "ringing" at 12:00 AM.
I am a beginner in Java and I am a little lost. I believe I have most of the skeletal work done. This is much like another question asked on here but I could not find an answer to my problems. So I apologize for the similarity. I am also to create a "dummy driver" in order to test the method as one of the requirements for this program is to be able to be read by a general driver someone else has created. Therefore, all of my variables and methods must be left the way I have them in order to be read by said driver. I wish I could be a little more specific in what I need assistance with but any feedback you can give me is much appreciated.
This is what I've got so far:
//dummy driver
package program5;
public class Program5 {
public static void main(String[] args) {
AlarmClock alarm = new AlarmClock();
System.out.println(alarm.getHour() + ":" + alarm.getMinute() + alarm.getAmOrPM());
System.out.println(alarm.getAlarmHour() + ":" + alarm.getAlarmMinute() + alarm.getAlarmAmOrPm());
System.out.println(alarm.isIsAlarmRinging());
}
}
package program5;
public class AlarmClock {
private int hour;
private int minute;
private String amOrPm;
private int alarmHour;
private int alarmMinute;
private String alarmAmOrPm;
private boolean isAlarmRinging;
//constructor:
AlarmClock() {
hour = 12;
alarmHour = 12;
minute = 0;
alarmMinute = 0;
alarmAmOrPm = new String();
amOrPm = new String();
isAlarmRinging = false;
}
//getters:
public int getHour() {
if ((hour >= 1) && (hour <= 12)) {
}
return hour;
}
public int getMinute() {
if ((minute >= 0) && (minute <= 59)) {
}
return minute;
}
public String getAmOrPM() {
return amOrPm;
}
public int getAlarmHour() {
return alarmHour;
}
public int getAlarmMinute() {
return alarmMinute;
}
public String getAlarmAmOrPm() {
return alarmAmOrPm;
}
public boolean isIsAlarmRinging() {
if (hour >= 12){
isAlarmRinging = true;
}
return isAlarmRinging;
}
//setters
public void setHour(int newHour) {
if ((newHour >= 1) && (newHour <= 12)) {
hour = newHour;
}
}
public void setMinute(int newMinute) {
if ((newMinute >= 0) && (newMinute <= 59)) {
minute = newMinute;
}
}
public void setAmOrPM(String newAmOrPm) {
amOrPm = newAmOrPm;
}
public void setAlarmHour(int newAlarmHour) {
if ((newAlarmHour >= 1) && (newAlarmHour <= 12)) {
alarmHour = newAlarmHour;
}
}
public void setAlarmMinute(int newAlarmMinute) {
if ((newAlarmMinute >= 0) && (newAlarmMinute <= 59)) {
alarmMinute = newAlarmMinute;
}
}
public void setAlarmAmOrPm(String newAlarmAmOrPm) {
alarmAmOrPm = newAlarmAmOrPm;
}
public void setIsAlarmRinging(boolean isAlarmRinging) {
if (isAlarmRinging = true) {
System.out.println("Ringing!");
}
}
public void advanceOneMinute() {
minute++;
if (minute == 59) {
hour++;
}
}
public void advanceMinutes(int minutesToAdvance) {
}
public void advanceOneHour() {
hour++;
if (hour > 12) {
hour = 1;
}
}
public void advanceHours(int hoursToAdvance) {
}
public void setTime(int newHour, int newMinute, String newAmOrPm) {
hour = newHour;
amOrPm = newAmOrPm;
}
public void setAlarmTime(int newAlarmHour, int newAlarmMinute, String newAlarmAmOrPm) {
if(hour >=0 && hour <= 23 && minute >=0 && minute <= 59) {
newAlarmHour = hour;
newAlarmMinute = minute;
}
}
public void turnOffAlarm() {
isAlarmRinging = false;
}
public void displayTime() {
}
public void displayAlarmTime() {
}
}
It's far from done but it's a start. If you can tell me anything I can do, I'll be very thankful. I'm not sure exactly what my question is. Just if I'm on the right track and what I'm doing wrong. Sorry it's not a short, concise, clear-cut question.