The error message that is showing up when I attempt to run my code is:
Exception in thread "main" java.lang.UnsupportedOperationException: Not supported yet.
C:\Users\Violettwilight\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)
And my code is as follows ( I should mention a large chunk of this code has been copied from source code from the course book-per professors instructions. I just had to make a few tweeks):
That Exception looks like what you get from NetBeans if you tell is to create a class with a number of methods. All methods have this structure (or similar):-That is useful for development; if you try a method which you have not yet completed, you suffer an Exception and you know about it. When you implement each method, you are supposed to delete the line about the Exception.
There is something not right about your drug methods. I think you should have a Drug class with name and mg per kilo fields instead of those methods. What is the 2.2 Is that some sort of conversion between lb and kg? Surely it is 2.205?
Yes I think OP didn't consider other animals. It would be easy if we create a separate class named Pet which will have these fields String petName, int petAge, float petWeight and String petType.
Campbell Ritchie wrote:Agree about braces but not about the field speciesDog. You are going to create dreadful spaghetti code if you try all those fields. What about cats, and calculating the dose of morphine? You will have to think again about different dosages for different species.
Ohh I see, you mean declare common fields of Pets in Pet abstract class. Common behaviours of Pets comes in Pet abstract class like (Just assumed) sleeping(), drinkingWater() as defined methods of Pet abstract class whose implementation we know and methods (behaviour) which are type specific like makeNoise() where Dog barks and Cat meows so their implementation will be in respective classes i.e. type specific. Means when we know partial implementation then go for abstract class and when have no idea of implementation then go for interface, hope I'm correct?
Campbell Ritchie wrote:Maybe. But surely you are better off having an abstract Pet class and subclasses Dog, Cat, etc etc.