Ok so I wrote this with some help of a friend and it compiles fine and everything, however when I try and run it I get this error message.
"Static Error: No constructor in Day matches this invocation
Arguments: ()
Candidate signatures: Day(int)"
I am not sure what this means or how to fix it to run. Any help would be appreciated. Also this program is supposed to do the following.
Design and implement the class Day that implements the day of the week in a program. The class Day should store the day, such as Sun for Sunday. The program should be able to perform the following operations on an object of type Day:
a) Set the day.
b) Print the day.
c) Return the day.
d) Return the next day.
e) Return the previous day.
f) Calculate and return the day by adding certain days to the current day. For example, if the current day is Monday and we add four days, the day to be returned is Friday.
g) Add the appropriate constructors.
h) Write a program to test various operations on the class Day.
-thanks-
public class Day
{
final static int SUNDAY = 0;
final static int MONDAY = 1;
final static int TUESDAY = 2;
final static int WEDNESDAY = 3;
final static int THURSDAY = 4;
final static int FRIDAY = 5;
final static int SATURDAY = 6;
public int day;
public Day(int day)
{
this.day = day;
}
public void setDay(int day)
{
this.day = day;
}
public int getDay()
{
return day;
}
public void print()
{
System.out.println(this.toString());
}
public int nextDay()
{
int next;
next = day + 1;
return next;
}
public int previousDay() {
int prevDay;
prevDay = day - 1;
return prevDay;
}
public int addDays(int days)
{
return (day + days) % 7;
}
public String toString()
{
switch (this.day)
{
case SUNDAY:
return "Sunday";
case MONDAY:
return "Monday";
case TUESDAY:
return "Tuesday";
case WEDNESDAY:
return "Wednesday";
case THURSDAY:
return "Thursday";
case FRIDAY:
return "Friday";
case SATURDAY:
return "Saturday";
}
return "";
}
public static void main(String[] args)
{
System.out.println("Test Day");
System.out.println();
System.out.print("Set day: ");
Day d = new Day(SUNDAY);
d.print();
System.out.print("Next day: ");
d.setDay(d.nextDay());
d.print();
System.out.print("Previous day: ");
d.setDay(d.previousDay());
d.print();
System.out.print("After 4 days: ");
d.setDay(d.addDays(4));
d.print();
}
}