Results 1 to 12 of 12
- 05-18-2010, 12:39 PM #1
Member
- Join Date
- May 2010
- Posts
- 6
- Rep Power
- 0
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
:(
- 05-18-2010, 12:44 PM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
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.
-
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!
- 05-20-2010, 03:27 AM #4
Member
- Join Date
- May 2010
- Posts
- 6
- Rep Power
- 0
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.
- 05-20-2010, 03:31 AM #5
Senior Member
- Join Date
- May 2010
- Posts
- 436
- Rep Power
- 4
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!
- 05-20-2010, 03:33 AM #6
Member
- Join Date
- May 2010
- Posts
- 6
- Rep Power
- 0
- 05-20-2010, 03:38 AM #7
Senior Member
- Join Date
- May 2010
- Posts
- 436
- Rep Power
- 4
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!
- 05-20-2010, 03:42 AM #8
Senior Member
- Join Date
- Mar 2010
- Posts
- 953
- Rep Power
- 4
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-
- 05-20-2010, 02:55 PM #9
Member
- Join Date
- May 2010
- Posts
- 6
- Rep Power
- 0
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
TestFeedback.javapublic 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;
}
}
I am weak in java, so can help me check have I fulfilled Part A, B and Part C or notpublic 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());
}
}
Or have I miss out any of the three parts or miss out any requirements
?
- 05-20-2010, 03:48 PM #10
do you know what a constructor is?
Create usingJava 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; }
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 ~-'
- 05-20-2010, 03:52 PM #11
Member
- Join Date
- May 2010
- Posts
- 6
- Rep Power
- 0
@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 !
- 05-20-2010, 04:00 PM #12
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
-
i have a question on my assignment??(java)
By javanew in forum New To JavaReplies: 4Last Post: 03-27-2010, 11:15 PM -
Java syntax I don't understand - assignment
By poet in forum New To JavaReplies: 2Last Post: 09-19-2009, 06:47 AM -
Java assignment
By xtianah77 in forum New To JavaReplies: 1Last Post: 02-17-2008, 11:54 PM -
java assignment, need help bad.
By carlos123 in forum New To JavaReplies: 1Last Post: 11-06-2007, 04:53 PM -
Help with my assignment java
By toby in forum New To JavaReplies: 1Last Post: 08-07-2007, 05:59 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks