learning java here, still a beginner. i am currently using blue jay and am getting the error missing return statement. here i have a method i am creating for getting the day of the week to return a string,i am also using the getValue() method from another class, the getValue method from my other class only returns ints, so i created a local variable to compare the values with the constants i have representing days of the week, here are my constants from my class and below that the method that im having issues with. thanks alot.
private NumberDisplay dayNumber;
public static final int NUMBER_OF_DAYS_IN_WEEK = 7;
public static final int SUNDAY = 0;
public static final int MONDAY = 1;
public static final int TUESDAY = 2;
public static final int WEDNESDAY = 3;
public static final int THURSDAY = 4;
public static final int FRIDAY = 5;
public static final int SATURDAY = 6;
public static final String SUNDAY_STRING = "Sunday";
public static final String MONDAY_STRING = "Monday";
public static final String TUESDAY_STRING = "Tuesday";
public static final String WEDNESDAY_STRING = "Wednesday";
public static final String THURSDAY_STRING = "Thursday";
public static final String FRIDAY_STRING = "Friday";
public static final String SATURDAY_STRING = "Saturday";
public String getDayOfTheWeek()
{
int today = dayNumber.getValue();
if (today == SUNDAY)
{
return SUNDAY_STRING;
}
else if (today == MONDAY)
{
return MONDAY_STRING;
}
else if (today == TUESDAY)
{
return TUESDAY_STRING;
}
else if (today == WEDNESDAY)
{
return WEDNESDAY_STRING;
}
else if (today == THURSDAY)
{
return THURSDAY_STRING;
}
else if (today == FRIDAY)
{
return FRIDAY_STRING;
}
else if(today == SATURDAY)
{
return SATURDAY_STRING;
}
}
Aucun commentaire:
Enregistrer un commentaire