title: Java: Error with constructors and passing variables
body: <p>I am trying to input a date in the format <code>dd mm yyyy</code> and have to return in the format e. g. <code>Tuesday, 29th September</code>. I'm new to Java and am not sure if my values from the day, month, year classes are being returned to the main. There is an error for the <code>Date date1 = new Date(day1, month1, year1)</code> saying it is undefined and to make it a constructor. If I make it a constructor and run the program I get values back like <code>lab2.Day@659e0bfd</code>. Not sure where to go from here.  </p>
  
  <pre><code>package lab2;
  
  public class Calendar {
  
  //assume all months have 30 days and that 1 January is a Monday;
  
  public static void main(String[] args) { // e.g. input: 29 09 2015
  
      int in1 = Integer.parseInt(args[0]);
      int in2 = Integer.parseInt(args[1]);
      int in3 = Integer.parseInt(args[2]);
  
      Day day1 = new Day(in1, in2); // string
      Month month1 = new Month(in2); // string
      Year year1 = new Year(in3); // integer
  
  
       Date date1 = new Date(day1, month1, year1); //
  
      date1.printName(); // e.g. "The date is Tuesday, 29th of September, 2015
  
  }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>package lab2;
  
  public class Day {
  private int day;
  private int month;
  private int code;
  private String name; //e.g. Tuesday 
  
  public Day(int dy, int mth ){
      day = dy;
      month = mth;
      code = ((day*month) % 7);
  
  
      // Assigning the day variable number to text //
      switch (code) {
      case 0: name = "Monday";
              break;
      case 1: name = "Tuesday";
              break;
      case 2: name = "Wednesday";
              break;
      case 3: name = "Thursday";
              break;
      case 4: name = "Friday";
              break;
      case 5: name = "Saturday";
              break;
      case 6: name = "Sunday";
              break;
      default: System.out.println("Incorrect Day Entered");}
  
      }
  
  }
  </code></pre>
  
  <hr>
  
  <pre><code>package lab2;
  
  public class Month {
  
  private int month1;
  private String monthName;
  
  
  
  
  public Month(int temp1){
      month1=temp1;
  
  
  switch (month1) {
  case 1: monthName = "January";
          break;
  case 2: monthName = "February";
          break;
  case 3: monthName = "March";
          break;
  case 4: monthName = "April";
          break;
  case 5: monthName = "May";
          break;
  case 6: monthName = "June";
          break;
  case 7: monthName = "July";
          break;
  case 8: monthName = "August";
          break;
  case 9: monthName = "September";
          break;
  case 10: monthName = "October";
          break;
  case 11: monthName = "November";
          break;
  case 12: monthName = "December";
          break;
  default: System.out.println("Incorrect Month Error");}
  
  
  }
  
  }
  </code></pre>
  
  <hr>
  
  <pre><code>package lab2;
  
  public class Year {
  
  private int yearNumber;
  
  public Year(int temp2)
  {
      yearNumber=temp2;
  
  
  }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>package lab2;
  
  public class Date {
  
  private String day;
  private String month;
  private int year;
  
  
  
   public Date(String temp1, String temp2, int temp3){
      day = temp1;
      month = temp2;
      year = temp3; 
      }
  
  
  
  public void printName() {
      System.out.println("The date is " +day+ ", " +month+ ", " +year);
  }
  
  } 
  </code></pre>