Results 1 to 12 of 12
  1. #1
    Join Date
    May 2010
    Posts
    6
    Rep Power
    0

    Default My java assignment -- please help me !

    I am quite new to java, and now I have a problem -- my teacher wants us to do a java assignment.

    Here are the details:
    Make a class diagram and an object diagram for creating users or customers or products etc. (just an object example and work on it)

    Implement class diagram in Java and include these:
    (a)
    At least 2 constructors
    Get and Set accessor methods (accessor and mutators) for all relevant attributes. You may want to do error checkings in these methods, if necessary

    Any methods that you think would be required.
    For example, if you wrote a “User” class, then you might need to write a method:
    public boolean authenticate(String pwd) { … }

    (b)
    Create a Java application (with the main() method) that uses the class you created in (a):
    Use two different constructors, create at least 2 objects from the class in (a)
    Call all the methods that you have created in (a). Use the mutators to change the attributes, and use the accessor to get the attributes.

    I not sure how to do, and neither do I know how to use the codes.

    Please help. If possible, share with me your codings for my assignment.
    I am really left with no choice already.

    I doing it on Eclipse JavaEE

    :(

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    What have you done so far?
    Don't ask for people's "codings".
    Rather try it and ask for specific help when you get stuck.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by java_beginner1 View Post
    I not sure how to do, and neither do I know how to use the codes.

    Please help. If possible, share with me your codings for my assignment.
    I am really left with no choice already.
    I agree with r035198x. No one is going to do this for you, nor should they. Our goal here is to help folks learn Java, not to do their homework for them. So if you show your work, describe how it doesn't work or what errors occur, and ask specific questions about something you don't understand, most will enthusiastically help you.

    Much luck!

  4. #4
    Join Date
    May 2010
    Posts
    6
    Rep Power
    0

    Default

    I apologise for some misunderstandings here.

    I have more or less figured out the codes.

    So now, I am trying to open my project.

    I start up eclipse, and there, at the ''select a workspace'' part, i browser to this:
    C:\Users\Personal\Desktop\Feedback (this is where my project, named Feedback, is saved). Then I click ok.

    However, after I click ok, and eclipse loads itself, under Project Explorer, there is nothing at all. Where has my project Feedback gone to ?

    I can't open my project !

    Please help.

  5. #5
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    This is not really a Java question but rather an Eclipse question. You may wish to check out their help files and also check for an Eclipse support forum for this problem.

    Buena suerte!

  6. #6
    Join Date
    May 2010
    Posts
    6
    Rep Power
    0

    Default

    Quote Originally Posted by curmudgeon View Post
    This is not really a Java question but rather an Eclipse question. You may wish to check out their help files and also check for an Eclipse support forum for this problem.

    Buena suerte!
    basically you are also unsure why i can't open my project, right ?

    thanks a lot

  7. #7
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    Quote Originally Posted by java_beginner1 View Post
    basically you are also unsure why i can't open my project, right ?thanks a lot
    Basically, Eclipse works for me. Based on what you're describing, no, I don't know why it's not working for you.

    But since your question has now changed 180 degrees from the original post and in fact has veered away from standard Java, you may have better luck getting a decent answer by checking out sites of Eclipse expertise. If you do ask this elsewhere, most would appreciate your posting a link to the cross-post and letting us know if and how you get this resolved.

    Your mileage may vary.

    Otra vez, buena suerte!

  8. #8
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    Quote Originally Posted by java_beginner1 View Post
    I apologise for some misunderstandings here.

    I have more or less figured out the codes.

    So now, I am trying to open my project.

    I start up eclipse, and there, at the ''select a workspace'' part, i browser to this:
    C:\Users\Personal\Desktop\Feedback (this is where my project, named Feedback, is saved). Then I click ok.

    However, after I click ok, and eclipse loads itself, under Project Explorer, there is nothing at all. Where has my project Feedback gone to ?

    I can't open my project !

    Please help.
    Workspace is not one individual project, but a collective directory for all your Eclipse projects. You should probably put your workspace in C:\Users\Personal\workspace (or C:\Users\<username>\workspace if you have a user name). Then your Feedback project will go in workspace\Feedback.

    You are getting good advice from others when they say to visit an Eclipse forum, or to look for Eclipse instructions.

    -Gary-

  9. #9
    Join Date
    May 2010
    Posts
    6
    Rep Power
    0

    Default

    I am stuck at this part.

    (part c)
    A Java application (with the main() method) that uses the class you created in (part b):
    Using two different constructors, create at least 2 objects from the class in (part b)
    Call all the methods that you have created in (part b). Use the mutators to change the attributes, and use the accessor to get the attributes.

    (look at my starting post for part B requirements.)

    How do I do it ? Seriously, I have no idea how. I feel very desperate nowfor answers :(

    here are the codings (two java files)

    Feedback.java
    public class Feedback {
    private String Name;
    private String Topic;
    private String Description;

    public String getName(){
    return Name;
    }
    public String getTopic(){
    return Topic;
    }
    public String getDescription(){
    return Description;
    }

    public void setName (String n){
    Name= n;
    }
    public void setTopic (String T){
    Topic= T;
    }
    public void setDescription (String D){
    Description= D;
    }
    }
    TestFeedback.java
    public class TestFeedback {
    public static void main(String[] args){
    Feedback U1 = new Feedback ();
    U1.setName("Ah Huat");
    U1.setTopic ("Topic : Compliment");
    U1.setDescription ("Your company has provided good services, and your website is well built.");

    Feedback U2 = new Feedback ();
    U2.setName ("Ah Hia");
    U2.setTopic ("Topic : Suggestion");
    U2.setDescription ("May I suggest that the company change the script of the website, as well as the fonts used for the word ? I find it hard to navigate your website. Thanks a lot");

    System.out.println (U1.getName());
    System.out.println (U1.getTopic());
    System.out.println (U1.getDescription());

    System.out.println (U2.getName());
    System.out.println (U2.getTopic());
    System.out.println (U2.getDescription());

    }
    }
    I am weak in java, so can help me check have I fulfilled Part A, B and Part C or not
    Or have I miss out any of the three parts or miss out any requirements

    ?

  10. #10
    Sno's Avatar
    Sno
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Posts
    196
    Rep Power
    5

    Default

    do you know what a constructor is?
    Java Code:
    public Feedback(){
    String Name = "";
    String Topic = "";
    String Description = "";
    }
    
    or
    
    public Feedback(String name, String topic, String description){
    String Name = name;
    String Topic = topic;
    String Description = description;
    }
    Create using

    Feedback Feed = new Feedback();
    or
    Feedback Feed = new Feedback("Jack","Computer Science","Description here");

    of course just placing strings in place of the quotes would be easier.
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

  11. #11
    Join Date
    May 2010
    Posts
    6
    Rep Power
    0

    Default

    @sno -- thanks a lot !

    however, according to the codes you provided, if i use them, i place them on TestFeedback.java or Feedback.java ?

    thanks !

  12. #12
    Sno's Avatar
    Sno
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Posts
    196
    Rep Power
    5

    Default

    Feedback

    Think of it like this,
    when you see
    Feedback Feed = new Feedback();

    mentally imagine an object (for example a piece of paper) and you are writing on this piece of paper, a name, a topic and a description, and a constructor is setting up the properties of what is on your paper,

    the other class your have (testFeedback) is a director, he is the one who writes on the paper, so you tell him what to set(write) on the paper, or get (read) off the paper
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

Similar Threads

  1. i have a question on my assignment??(java)
    By javanew in forum New To Java
    Replies: 4
    Last Post: 03-27-2010, 11:15 PM
  2. Java syntax I don't understand - assignment
    By poet in forum New To Java
    Replies: 2
    Last Post: 09-19-2009, 06:47 AM
  3. Java assignment
    By xtianah77 in forum New To Java
    Replies: 1
    Last Post: 02-17-2008, 11:54 PM
  4. java assignment, need help bad.
    By carlos123 in forum New To Java
    Replies: 1
    Last Post: 11-06-2007, 04:53 PM
  5. Help with my assignment java
    By toby in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 05:59 AM

Posting Permissions

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