All things are lawful, but not all things are profitable.
All things are lawful, but not all things are profitable.
All things are lawful, but not all things are profitable.
All things are lawful, but not all things are profitable.
Liutauras Vilda wrote:6. command.equals("COLOUR") it seems program is not meant to be created for US market, no worries for that, that was more of a puzzle
The 4 is part of the expression which continues with && on the next line; the // starts a line end comment. The 4 comes up the same colour as the comment in the code tags.A few minutes ago, I wrote:. . .
args.length == 4 // COLOUR r g b makes 4 elements
. . .
No, don't print an error message in that message. Any error messages are the responsibility of something else. Also make sure to return a boolean from that method, or throw an exception in the case of an error. Don't return Strings.Kirk Preston wrote:. . .
All things are lawful, but not all things are profitable.
if I have a text file with either MOVE , MOVE 100, these should be invalid and generate an error message, if I have a text file with MOVE 100 200 this is valid.
All things are lawful, but not all things are profitable.
A typical Op would look like this:Carey Brown wrote:I think I would have taken a different design approach. Rather than having individual validators I would have called constructors for individual DrawingOperations (e.g. TextOp). Letting the constructor throw an exception if the arguments are invalid. Each DrawingOperation would implement a draw( Graphics2D ) method. The main program would add each Op to a list and when done creating a list of all of the Op's, loop through the list calling draw().
/what you are doing by that is signalling that you think the current constructor shouldn't handle the Exception or it is beyond the capabilities of the constructor to handle it; any corrections need to be done elsewhere.Carey Brown wrote:. . . throwing an exception when there's a problem with the command line. Notice that there is no try/catch block around parseInt(), we just let any exception it may throw propagate up. . . .
Exactly. Good explanation.Campbell Ritchie wrote:
/what you are doing by that is signalling that you think the current constructor shouldn't handle the Exception or it is beyond the capabilities of the constructor to handle it; any corrections need to be done elsewhere.Carey Brown wrote:. . . throwing an exception when there's a problem with the command line. Notice that there is no try/catch block around parseInt(), we just let any exception it may throw propagate up. . . .
Normally trees don't drive trucks. Does this tiny ad have a license?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|