I'm learning about inheritance and polymorphism in my CS class and thought it'd be a good idea to find something I could apply myself to. I have a lot of ideas, and sometimes there's things I want to do and things I don't want to do. Why not leave the decision-making up to Java?
I'm looking for feedback to make my code better: whether it's something I could do with readability or inheritance, or even data structure wise. Or if there's bugs that'd be nice to know too :)
There are multiple classes extending MakeChoice, I just didn't put them here.
import java.util.*;
public class MakeChoice {
// main
public static void main(String[] args) {
makeChoice makerShareChoice = new makeChoiceMakerShare();
System.out.println(makerShareChoice);
}
public static int getChoiceForArrayList(int size) {
int choice = generateRandomIntRange(0, size - 1);
return choice;
}
public static int generateRandomIntRange(int min, int max) {
int range = (max - min) + 1;
int random = (int) (Math.random() * range + min);
return random;
}
}
import java.util.*;
public class MakeChoiceMakerShare extends makeChoice {
private static ArrayList<String> choices = new ArrayList<String>();
public makeChoiceMakerShare() {
super();
choices.add("acrylic LED");
choices.add("MESA EduPi");
choices.add("Collage of whiteboard wall");
choices.add("sponge mitts");
choices.add("hooks in closet");
choices.add("10 x 10 LED Matrix");
choices.add("What should I make? CoMotion addition to matrix");
choices.add("What should I do this week? Screen");
choices.add("Lasercraft belt + UW belt buckle + Wallet");
}
public String toString() {
return "Your choice for this week in " + this.getClass() + " is: " + choices.get(getChoiceForArrayList(choices.size()));
}
}