The answer for the given question is explained below.
Explanation:
public class Parking Meter
{
int time Left = 0;
int max Time;
public Parking Meter( int max ){
max Time = max;
}
public boolean add ( int coin )
{
if ( coin == 25 )
{
if ( time Left + 30 < max Time )
{
time Left += 30;
return true;
}
}
return false;
}
public void tick()
{
if ( time Left > 0 )
{
time Left -= 1;
}
}
public boolean is Expired()
{
return time Left == 0;
}
}