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 6 of 6

Thread: Exercises - CRITICAL HELP NEEDED

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Exercises - CRITICAL HELP NEEDED

    Could someone help me with my exercises, because I suck at java programming and I need to get these done before my course ends.

    I beg of you to help me..

    Here goes nothing,

    You can find the files mentioned in the exercises from here:
    Index of /maximillian

    First exercise:
    In this task, you write a test class that adds multiple Shirt objects to an
    Order object and displays a total current amount, in dollars, for the order.
    Follow these steps to write your test class:
    1. Go to the working directory and open an editor.
    2. Open the Shirt.java file and examine the member variables and
    the method in it.
    3. Open the Order.java file and examine its member variables and
    method in it.
    4. Write a new class called OrderTest containing a main method.
    5. In the main method:
    a. Create and initialize an object of type Order and an object of
    type Shirt. The Order class (Order.java) and the Shirt class
    (Shirt.java) are provided in the exercise1 directory.
    b. Declare a variable of type double, name it as totalCost and
    initialize it by 0.0.
    c. Assign the price for the Shirt object to 14.00.
    d. Invoke the addShirt method of the Order class using the
    Order instance to add the shirt instance to the order. Store the
    return value of the addShirt method in the totalCost variable.
    The documentation for the addShirt method is as follows:
    public double addShirt (Shirt s)
    Adds a shirt to a list of shirts in an order
    Parameters:
    s – An object reference to a Shirt object
    Returns:
    A total current amount for the order
    e. Display the return order amount. For example:
    Total amount for the order is: 14.00
    6. Compile and execute your program. Verify if the total order value is
    displayed.
    7. In the main method of OrderTest class, create additional Shirt
    objects, assign values to the price variable of the new Shirt objects,
    and add the Shirt objects to your order by invoking the addShirt
    method.
    8. Save and compile the OrderTest.java file.
    9. Execute OrderTest class and verify that the total order value is
    displayed correctly.


    Second exercise:

    In this task, you write a Customer class with an overloaded method called
    setCustomerInfo.
    Follow these steps to write your class:
    1. Go to the working directory and open an editor.
    2. Create a class called Customer and save the file as Customer.java
    in the working directory.
    3. Within the Customer class, add two overloaded methods called
    setCustomerInfo.
    Depending on how the setCustomerInfo method is called, it does
    one of the following:
    ● Sets the ID, name, address, and phone number for a Customer
    object. (This is the minimum information needed for a new
    Customer.)
    ● Sets the ID, name, address, phone number, and email address
    for a Customer object.
    4. Create a display method to display the values of all the member
    variables of the Customer class.
    5. Save and close the Customer.java file.
    6. Open the file called CustomerTest.java to test the overloaded
    methods of the Customer class.
    Developing and Using Methods 1-7
    Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision A
    7. In the main method of CustomerTest class write code to perform the
    following tasks:
    a. Create two object references to different Customer objects.
    b. Use each variation of the setCustomerInfo method to provide
    information for each Customer object.
    c. Display the contents of each Customer object.
    8. Save and compile the file CustomerTest.java file.
    9. Execute the CustomerTest class and view the output of the class.

    Third Exercise:
    In this task, you create a class containing private attributes and try to
    access them in another class.
    Follow these steps to write your test class:
    1. Go to the working directory and open an editor.
    2. Create a class called DateOne that contains three member variables
    of type int named: day, month, and year. Give public access to all
    the member variables. Save the class with the name DateOne.java.
    3. Open the DateOneTest.java file provided in the working directory
    and write the following in its main method:
    a. Create and initialize an object of type DateOne.
    b. Assign different numeric values to the member variables of the
    DateOne instance.
    c. Display the value of the member variables of the DateOne
    instance.
    4. Save and compile DateOneTest.java file.
    5. Execute the DateOneTest class file and examine the output.
    6. Create a new class called DateTwo similar to DateOne with three
    member variables and save it as DateTwo.java.
    7. Modify the access specifier of the three member variables of DateTwo
    to private.
    8. Open the DateTwoTest.java file provided in the working directory
    and perform the same steps as in Step 3. However, in this case create
    an instance of DateTwo class instead of DateOne class. The other
    lines of code will remain the same.
    9. Save and compile DateTwoTest.java.
    10. Examine the compilation errors and identify the reason of the
    compilation errors.

    Fourth exercise:
    In this task, you create a class with private attributes and enable them to
    be manipulated from another class.
    Complete the following steps:
    1. Create a class called DateThree and save it with DateThree.java
    file name.
    2. DateThree class has the same three private member variables as
    DateTwo class.
    3. Add the following methods in the DateThree class:
    a. get and set methods for all three member variables. For
    example:
    public void setDay(int d) {
    day = d;
    }
    public int getDay() {
    return day;
    }


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Exercises - CRITICAL HELP NEEDED

    So where are you stuck and what is it you need help with?

    // Json

  3. #3
    Junior Member
    Join Date
    Nov 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Exercises - CRITICAL HELP NEEDED

    We got these exercises from our teacher, and no one in our class knows how to do them.

    So I'm stuck in all of them, can't do anything..

    I'm looking for a Javaguru to make these exercises for me, just this once so I can examine them.

    Please, help.

  4. #4
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Exercises - CRITICAL HELP NEEDED

    Sorry, no can do, get your self started and post some code when you run into problems and we'll do our best to give you a hand.

    // Json

  5. #5
    Junior Member
    Join Date
    Nov 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Exercises - CRITICAL HELP NEEDED

    My friend, Json..
    if you didn't understand the first time..
    NONE of our class knows how to do java, or even write a simple program.
    How do u think we'll be able to even start this thing, if we don't know what to do?

    Oh well, we're screwed then.. thanks a lot.

  6. #6
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,102
    Thanks
    169
    Thanked 779 Times in 725 Posts
    Blog Entries
    5

    Default Re: Exercises - CRITICAL HELP NEEDED

    No your not screwed, you just need to invest a bit of time. These exercises require very little knowledge of the java language, just some simple concepts that can be learned by spending a few moments reading the tutorials at the Sun website:
    Trail: Learning the Java Language (The Java™ Tutorials)

Similar Threads

  1. Urgent Help needed with java codes
    By makarov in forum Java Theory & Questions
    Replies: 0
    Last Post: November 13th, 2009, 06:23 AM
  2. Explanation on Arrays NEEDED
    By lamagiapc in forum Collections and Generics
    Replies: 4
    Last Post: November 7th, 2009, 10:36 PM
  3. code needed for the following problem
    By romilc in forum Java Theory & Questions
    Replies: 1
    Last Post: October 11th, 2009, 10:05 AM
  4. Urgent code needed
    By subhvi in forum AWT / Java Swing
    Replies: 4
    Last Post: August 27th, 2009, 12:55 AM
  5. Replies: 4
    Last Post: May 22nd, 2008, 10:59 AM