Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. /**
  2. * Created by Tim on 9/25/2017.
  3. */
  4.  
  5. public class Day_Tim {
  6. static String day[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
  7. string theDay;
  8. Day_Tim(String startDay){
  9. this.day = startDay;
  10. }
  11. public void setDay(String day[]){
  12. this.day = day;
  13. }
  14. public void printDay(int id){
  15. System.out.println("The day of the week is " + day[id]);
  16. }
  17.  
  18. public String getDay(int id){
  19. return day[id];
  20. }
  21. public String nextDay(int id){
  22. if (id > 0 && id < 7)
  23. return day[id + 1];
  24. else
  25. return day[(id % 7) + 1];
  26. }
  27. public String previousDay(int id){
  28. if (id > 0 && id < 7)
  29. return day[id - 1];
  30. else
  31. return day[(id % 7) - 1];
  32. }
  33. public String calculateDay(int id, int add){
  34. if (id + add > 0 && id + add < 7)
  35. return day[id + add];
  36. else
  37. return day[(id + add) % 7];
  38. }
  39.  
  40. public static void main(String[] args){
  41. Day_Tim day = new Day_Tim("Monday");
  42. System.out.println(day);
  43.  
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement