Ok..I hope that your prof answered little bit longer than that because Cloneable interface is empty. It just indicates to the Object.clone() method that it is legal for that method to make a field-for-field copy of instances of that class (ref. docs.oracle.com/javase/7/docs/api/...). And because remote control should be only be were of Command interface, which doesn't have a copy-method, you still have the problem orginal problem how do you create a copy of an object which implements Command interface without doing something nasty. My solution would be that the Command interface would look something like this:
void execute();
void undo();
<T extends Command> T createCopy();
Now the remote control can create easily copies.
But yeah I think this is enough chit chat about this topic :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Ok..I hope that your prof answered little bit longer than that because Cloneable interface is empty. It just indicates to the Object.clone() method that it is legal for that method to make a field-for-field copy of instances of that class (ref. docs.oracle.com/javase/7/docs/api/...). And because remote control should be only be were of Command interface, which doesn't have a copy-method, you still have the problem orginal problem how do you create a copy of an object which implements Command interface without doing something nasty. My solution would be that the Command interface would look something like this:
Now the remote control can create easily copies.
But yeah I think this is enough chit chat about this topic :)