Thank you for your previous help. However I have another question:
I have three classes MovieRating class, Adult class, and Child class.
The Child class and Adult class both have a method canWatchmovie(MovieRating mrating)
in the Adult class the method always return true while in the Child class we must check the child's age to determine if they can watch movie or not. below is my code:

//MovieRating class

import java.util.*;

public class MovieRating 
{
    private Map ageMap = new HashMap();
    public MovieRating()
    {  
        ageMap.put("PG", 18); //parental Guidance
        ageMap.put("G", 4);  //general viewing
        ageMap.put("A", 27);  //Adult material
    }  

    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("G"));
        if (age < mAge )
        {
            return false;            
        }
        else if (age >= mAge)
        {
            return true;
        } 
        return false;
   }
    public int getMinAge() 
    {
         // 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();
    }

}

// method canWatchMovie in the Child class

public boolean canWatchMovie(MovieRating mrating) 
   {
       //some code for checking the age property and movie rating here
       return false
    }

Some help please, I'm new to this java language.


public boolean canWatchMovie(MovieRating mrating)
{
//some code for checking the age property and movie rating here
return false
}

...
private String status = null;
private int age = 0;
// use setters to put the right values in those
...
public boolean canWatchMovie(MovieRating mRating){
  return mRating.getStatus(this.status, this.age);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.