In: Computer Science
import java.util.ArrayList;
public class Workouts {
public enum Muscle {ABS, BACK, BICEPS, CHEST, FOREARM, GLUTES,
LOWERLEG, SHOULDER, TRICEPS, UPPERLEG, NONE} // Why didn't I have
to declare this static?
public enum Equipment {BARBELL, BODYWEIGHT, DUMBBELL, CABLE,
HAMMERSTRENGTH}
private final ArrayList<Workout> workoutList =
new ArrayList<Workout>();
// You will need to create a number of methods for the
inner class. You are not limited to
// only the methods listed inside this class.
private class Workout {
private String name;
private Equipment equipment;
private Muscle primaryMuscle;
private Muscle
secondaryMuscle;
private String desc;
private String reminders;
Workout(String name, Equipment equipment, Muscle primaryMuscle,
Muscle secondaryMuscle, String desc, String reminders)
{
// How do we get the name of an enumeration value?
//should instantiate an instance of the workout class
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
I would like help on the constructor
class Workouts {
public enum Muscle {
ABS, BACK, BICEPS, CHEST, FOREARM, GLUTES, LOWERLEG, SHOULDER, TRICEPS, UPPERLEG, NONE
} // Why didn't I have to declare this static?
// Because The Enums are used by your class methods and innner class.
// a inner class like Workout, always work in tandem with the outer class.. so
// it can access members of outer class, and hence the enums
public enum Equipment {
BARBELL, BODYWEIGHT, DUMBBELL, CABLE, HAMMERSTRENGTH
}
private final ArrayList<Workout> workoutList = new ArrayList<Workout>();
// You will need to create a number of methods for the inner class. You are not
// limited to
// only the methods listed inside this class.
private class Workout {
private String name;
private Equipment equipment;
private Muscle primaryMuscle;
private Muscle secondaryMuscle;
private String desc;
private String reminders;
public Workout(String name, Equipment equipment, Muscle primaryMuscle, Muscle secondaryMuscle, String desc,
String reminders) {
this.name = name;
this.equipment = equipment;
this.primaryMuscle = primaryMuscle;
this.secondaryMuscle = secondaryMuscle;
this.desc = desc;
this.reminders = reminders;
// How do we get the name of an enumeration value?
//should instantiate an instance of the workout class
// If you want just the string value of a enum, you can do below:
// primaryMuscle.toString()
}
}
}