I'm attempting to access values that are held inside a Class which is listed in a HashMap.
In my first class I create a HashMap which links to the "LiftingStats" class.
Map<String, LiftingStats> fitnessGoals = new HashMap<String, LiftingStats>();
In the LiftingStats class I do the following...
public class LiftingStats
{
public String activity;
public String weightType;
public int weight;
public double difficulty;
/**
* Constructor for objects of class LiftingStats
*/
public LiftingStats()
{
this.run();
}
/**
* test method to fill values
*/
public void run(){
//code
this.activity = "bench press";
this.weightType = "Kg";
this.weight = 100;
this.difficulty = 8.5;
}
I'm running a test method to fill the hashmap with some values
public void testMethod(){
fitness.put("activityone", new LiftingStats());
fitness.put("activitytwo", new LiftingStats());