package Proxy;
public abstract class Star
{
protected abstract int Appear();
}
package Proxy;
public interface ITax
{
double Tax(double dVal);
}
package Proxy;
import java.util.Random;
import Proxy.Star;
import Proxy.ITax;
public class Company
{//多继承代理 + 没有成功实现的强制代理
private Company()
{
}
static public class FilmStar extends Star
{
@Override
protected int Appear()
{
// TODO Auto-generated method stub
Random pRandom = new Random();
int iVal = pRandom.nextInt(100);
System.out.print("the star gains "+iVal+" $ " );
pRandom = null;
return iVal;
}
}
static public class ProxyStarTax extends Star implements ITax
{
public void Init(FilmStar pIStar)
{
if( null == m_pIStar)
m_pIStar = null;
m_pIStar = pIStar;
}
public void UnInit()
{
if( null == m_pIStar)
m_pIStar = null;
}
@Override
public double Tax(double dVal)
{
// TODO Auto-generated method stub
double dTax = (dVal*0.2);
System.out.print("the star tax: "+dTax+" $ " );
return dTax;
}
@Override
public int Appear()
{
// TODO Auto-generated method stub
int iVal = 45;//m_pIStar.Appear();
iVal = iVal - (int) Tax(iVal);
return iVal;
}
private FilmStar m_pIStar = null;
}
}