Results 1 to 3 of 3
  1. #1
    HaDesT is offline Member
    Join Date
    Mar 2010
    Posts
    1
    Rep Power
    0

    Default Define class and constructors

    Ok this is gonna be a long one. I'm new with this java thing and i need to coma out with a program with the criteria below:

    Define a class called Month. Your class will have one attribute of type int to
    represent a month (1 for January, 2 for February, and so forth). Include all the
    following methods in this class:
    (a) a constructor to set the month using the first three letters in the name of
    the month as three arguments (‘J’ ‘A’ ‘N’ for January, ‘F’ ‘E’ ‘B’ for
    February, and so forth),
    (b) a constructor to set the month using an integer as an argument (1 for
    January, 2 for February, and so forth),
    (c) a default constructor,
    (d) an input function that reads the month as an integer,
    (e) an input function that reads the month as the first three letters in the
    name of the month,
    (f) an output function that outputs the month as an integer,
    (g) an output function that outputs the month as the first three letters in the
    name of the month,
    (h) and a member function that returns the next month as a value of type
    Month.
    Test your class in a new program which has the main() method.

    I roughly know what to write at the beginning but my mind seem to be blank on how to write the conditions

    public class months {
    private int month;

    public months()
    {
    month = months[m];
    }

    public months(String m)
    {
    }
    public int MonthAsInt()
    {
    }
    public String MonthAsString()
    {
    }
    public months NextMonth()
    {
    }
    public String toString()
    {
    }
    }

    Do i need a return statement? Really need some guidance on what needs to be done to complete this program.

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    class called Month
    I don't see that anywhere.
    (b) a constructor to set the month using an integer
    I don't see that.
    And your skelleton code won't even compile as is. Don't try to do everyting at once. Start with b,c,d,f and get that running.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

Similar Threads

  1. define a variable
    By jperson in forum New To Java
    Replies: 2
    Last Post: 01-29-2010, 02:33 AM
  2. Define this error.
    By jaicea in forum New To Java
    Replies: 3
    Last Post: 12-02-2009, 01:07 AM
  3. How to define boolean in the fields ?
    By racewithferrari in forum New To Java
    Replies: 3
    Last Post: 11-26-2009, 06:01 PM
  4. Replies: 1
    Last Post: 05-19-2009, 11:03 PM
  5. Replies: 3
    Last Post: 11-17-2008, 03:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •