So, I think I have a pretty simple question. Say there is an open source Java program called com.cow.moo that you included in your com.bee.buzz project.
moo has a bunch of cool classes, most of which you don't want to touch, but there is a couple that you make. Now at this point, it is best to extend the classes you want to change, right? (I know that a lot has been said about continuations against guns, but none of these classes is an interface, so the question is nothing.)
My question is: let's say this is a class in moo:
package com.cow.moo;
public class Milk {
private float currentMilk;
public int getMilk() { }
public float convertToGallons (float liquid) { }
}
Now, let's say I just want to use getMilk in my new class, which extends Milk. However, getMilk in Milk relies on private variables (like currentMilk) and other functions that I won't include (like convertToGallons.) Do I have to include these other variables and functions if I want my new function to work correctly? I donβt want to change the function much, just add a little to it. What is the best way to do this?
General advice on creating a larger project can also be useful. I suggest that for some Java experts, it won't even take five seconds here to answer this question. Thank you for your time.
source
share