Alarm clock with "ringing" functionality 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 &gt;= 1) &amp;&amp; (hour &lt;= 12)) {
}
return hour;
}

public int getMinute() {
if ((minute &gt;= 0) &amp;&amp; (minute &lt;= 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 &gt;= 12){
isAlarmRinging = true;
}
return isAlarmRinging;
}

//setters
public void setHour(int newHour) {
if ((newHour &gt;= 1) &amp;&amp; (newHour &lt;= 12)) {
    hour = newHour;
}
}

public void setMinute(int newMinute) {
if ((newMinute &gt;= 0) &amp;&amp; (newMinute &lt;= 59)) {
    minute = newMinute;
}
}

public void setAmOrPM(String newAmOrPm) {
amOrPm = newAmOrPm;
}

public void setAlarmHour(int newAlarmHour) {
if ((newAlarmHour &gt;= 1) &amp;&amp; (newAlarmHour &lt;= 12)) {
    alarmHour = newAlarmHour;
}
}

public void setAlarmMinute(int newAlarmMinute) {
if ((newAlarmMinute &gt;= 0) &amp;&amp; (newAlarmMinute &lt;= 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 &gt; 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 &gt;=0 &amp;&amp; hour &lt;= 23 &amp;&amp; minute &gt;=0 &amp;&amp; minute &lt;= 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.
Calendar

You created an alarmclock, which is really just a time-representation. A Calendar has both a date and time component. I strongly, strongly suggest you use that so you can let your user define how he wants his date represented and let the API handle fancy stuff like timezones, summer hours, etc.

You can also look into the Java 8 time API but I think that might not be appropriate yet.

Enums

When you have a limited set of different possibilities, your mind should immediately wander to enums. This way you can represent your AM/PM by saying DayPart.AM and DayPart.PM instead of the literal string "AM" which could mistakenly be used as "aM", "am", "AX", etc. It will provide compile-time safety and is a lot more pleasant to work with.

Indentation

Stick to conventions. Some people indent a block with one tab (or 4 spaces), some with 2 spaces. This will keep the code readable for everyone.

Methods without a meaningful body

Look at your code here:

public int getHour() {
if ((hour &gt;= 1) &amp;&amp; (hour &lt;= 12)) {
}
return hour;
}


With formatting this becomes this:

public int getHour() {
    if ((hour &gt;= 1) &amp;&amp; (hour &lt;= 12)) {
    }

    return hour;
}


Can you tell what's wrong here? Note that there are several methods that have this construct!

Assignment vs Comparison

This is a very common mistake:

if (isAlarmRinging = true)


What you do here is set isAlarmRinging to true, you never compare it. 

Keep in mind:


Comparison: ==.
Assignment: =.


Unused parameters

In your method setTime you never use the parameter newMinute.
Likewise in method setAlarmTime you never use newAlarmAmOrPm.