I am quite new to java, and now I have a problem -- my teacher wants us to do a java assignment.
I doing it on Eclipse JavaEE
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.
(c)
A Java application (with the main() method) that uses the class you created in (b):
Using two different constructors, create at least 2 objects from the class in (b)
Call all the methods that you have created in (b). Use the mutators to change the attributes, and use the accessor to get the attributes.
I am stuck at part C.
How do I do it ? Seriously, I have no idea how. I feel very desperate now for 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
?
Your constructors are missing. And I don't see the point of question C as well, but anyway if you want a code sample, here's what I've written: