Hi, I have a class MovieRating below:
import java.util.*;
public class MovieRating
{
private Map ageMap = new HashMap();
private String movieRating;
public MovieRating()
{
ageMap.put("PG", 18); //parental Guidance
ageMap.put("G", 4); //general viewing
ageMap.put("A", 27); //Adult material
}
public String getRating()
{
return movieRating;
}
public boolean getStatus(String rating, int age)
{
int mAge,gAge,aAge;
mAge = Integer.getInteger((String) ageMap.get("PG"));
gAge = Integer.getInteger((String) ageMap.get("G"));
aAge = Integer.getInteger((String) ageMap.get("A"));
if (age < mAge )
{
return false;
}
else if (age >= mAge)
{
return true;
}
else if(age<aAge)
{
return false;
}
else if(age>=aAge)
{
return true;
}
else if(age<gAge)
{
return false;
}
else if(age>=gAge)
{
return true;
}
return false;
}
public int getPGuidance()
{
// Retrieve the minimum age allowed to watch movie rated PG.
return (Integer)ageMap.get("PG");
}
public int getGeneral()
{
// Retrieve the age allowed to watch movie rated G.
return (Integer)ageMap.get("G");
}
public int getAdult()
{
// Retrieve the age allowed to watch movie rated Adult.
return (Integer)ageMap.get("A");
}
public Object getValue()
{
// return ageMap.values();
return ageMap.toString();
}
}
In the public boolean getStatus(String rating, int age) method, i would like the method to get the movie rating and minimum age allowed to watch the movie, then compare with the age of the person to determine whether to return true or false. Can someone modify for me the getStatus() method.