In this assignment one has to build several classes.
Now my description of the problem, I hope it is not too cryptic (but I cannot give away too much).
The server gets input from a user by 'doPost':
Title, author, type, description etc.. Encapsulated in one
Java object.
That means I need variableslike:
String title;
in a method of a class.
And now the problem. This information is needed
in two (or more) classes and at my latest version each class (in a method) contructed the strings out of the one object and worked with them ...
Twice som 8 lines of code.
And Marilyn said: you doubled the code would you please look for a 'better' solution?!
A super class of both classes could be adjusted by getting a method extra, to be used in two (or more descendants).
BUT where to construct the strings? They are needed twice, first a check if the user did not forget to give a value and second to do something with it!
Is "protected String title;" allowed and even
as a side product set by the call in of the method?
I think this 'side-effect' is not nice.
So I am a little bit stuck and therefor I
need some advice.