• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with two methods of a class  RSS feed

 
Guillermo Rodriguez Barcelo
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a main class called User implemented as follows


And two classes that inherit from User that are Organizer and Participant implemented as follows

Organizer


Participant



I'm asked to implement the asOrganizer and asParticipant methods of the User class.
These methods must create an object of the specific class, and initialize the parent class with the data of the User object. To perform this task, you are prompted to implement the copy constructor of the User class.

I create the objects in the two methods that ask me but I should not do something well in the constructor because junit fails me

 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why have you got that no‑arguments constructor? I am sure you don't really want an object with empty Strings for all its fields.
Why have you got all those setXXX methods? Do you really want somebody changing your password like that?
Don't write if (...) return true; return false;. Look in the old Sun style guide and see what you shou‍ld write.
am afraid that I can't understand what is going wrong; you will have to provide more details please.
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I create the objects in the two methods that ask me but I should not do something well in the constructor because junit fails me 

What test does JUnit fail at?  You are asked to create a copy constructor.  Do you know what that is?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!