Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: help me plz =(

  1. #1
    Junior Member A.O.L's Avatar
    Join Date
    Sep 2012
    Location
    kuwait
    Posts
    2
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation help me plz =(


    Hi everyone

    i have homework in java programming using JCreator

    this is the Question is :

    create a class called date that includes 3 pieces of info as instance variables a month (type int) a day (type int) and a year (type int) . your class should have a constructor that initializes the 3 instance variables and assumes that the values provided are correct. provide a set and get method for each instance variables . provide a method displayDate that display the month, day and year separated by forward slashes (/). write a test application named dateTest that demonstrates class date's capabilities.

    i didnt get the idea right ....

    if any one can help plz do i will be grateful !


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: help me plz =(

    Welcome to the forums. Posting an assignment without showing an effort is what we call a 'homework dump', and will not get you much help. To make use of these forum, I recommend posting what you've tried and asking a specific question. The following might help:
    http://www.javaprogrammingforums.com...e-posting.html
    http://www.javaprogrammingforums.com...-get-help.html

  3. #3
    Junior Member A.O.L's Avatar
    Join Date
    Sep 2012
    Location
    kuwait
    Posts
    2
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: help me plz =(

    sorry about that but am really having a problem xx" am new student in Computer Sciences

    that what i did :
    public class Date
    {
    private int month;
    private int day;
    private int year;

    // constructor
    public Date(int a,int b,int c)
    {
    month = a;
    day = b;
    year = c;
    }

    // method
    public void getMonth(int x)
    {
    month= month+x;
    }
    public void getDay(int y)
    {
    day= day-y;
    }
    public void getYear(int z)
    {
    year= year-z;
    }

    // display
    public void displayDate()
    {
    System.out.printf("the initial date is %d/%d/%d\n", month,day,year);
    }

    }
    public class DateTest
    {
    public static void main(String args[])
    {
    Date V = new Date(7,4,2004);
    }

    V.getMonth(4);

    V.getDay(3);

    V.getYear(1);

    V.displayDate();

    System.out.printf("the new value date is %d/%d/%d\n", month,day,year);
    }
    and sorry again =\

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: help me plz =(

    Coming from the standpoint of someone using your code, I see a method named getMonth, or getDay, or getYear, I expect a method with this naming scheme to return a value to me. Your instructions say to provide a class with 3 type int, a getter and setter for each field, and a displayDate method. That comes to three variables and seven methods in a class. Then you are to demonstrate the use of the 7 methods interacting with the 3 fields in another class.

    You should research on keywords "java getters and setters" to see how your methods should look. Basically a getter will get and return the field you are after and a setter will set the field to the value supplied in the method call.

    When you post your code please use [code=java] before your code and [/code] after your code instead of the quote block. This will keep the formatting and highlight keywords to make the code easier to read. Plus it makes the forum pretty and easy to my old eyes.