You are mixing System.out.print and println. Use as few print calls as possible. If you can amalgamate two calls into one, you can save several milliseconds.
You have repeated code in lines 40 and 50, and 59 and 72. That should be refactored.
Why don't you attack the monster object directly?
You are going on about injuring the monster (surely a Knight would only kill a Dragon, and where is the PrettyMaiden class ?)
I meant, if you have several print calls, join them all together. NotbutThe "" + is to ensure everything is turned into Strings and may be unnecessary in many cases.
jonny Alva wrote: . . .
You said to use as few as possible, did you mean use System.out.println command as least as possible or did you mean use System.out.print as least as possible?
. . .
It is always bad to have repeated code. What happens if you need to maintain it and change that code? What happens if you have 99 bits of repeated code and there is an error and you only correct it 98 times?
Is it bad if i use a lot of the same code several times in java or is that like unprofessional?
. . .
Why not give the Monster a sufferAttack() method. That would be giving the monster a behaviour which there can be an interaction with.
How would i do that whould i just put the object as a parameter or not like that?
jonny Alva wrote:Actually, you just gave me a good idea, i'm going to see if i can make other characters here and see if i can have them do something here.
Oh and is it also possible to make an object pause for a min? like lets say the knight attacks and then it waits until it receives the attack of the monster?