JAVA多线程模拟停车场停车

package 课后习题;

class Park
{
	boolean  []park=new boolean[3];
	public boolean equals()
	{
		return true;
	}
	
}
class Car
{
	private String number;
	private int position=0;
	public Car(String number)
	{
		this.number=number;
	}
	public void setNumber(String number)
	{
		this.number=number;
	}
	public String getNumber()
	{
		return number;
	}
	public void setPosition(int i)
	{
		position=i;
	}
	public int getPosition()
	{
		return position;
	}
	public int hashCode()
	{
		return number.hashCode();
	}
	public boolean equals(Object obj)
	{
		if(obj==this)
			return true;
		if(obj!=null&&obj.getClass()==Car.class)
		{
			Car c=(Car)obj;
				return c.number==this.number;
		}
		return false;
	}
	}

class ParkCar implements Runnable
{
	Car c;
	Park p;
	public ParkCar(Car c,Park p)
	{
		this.c=c;
		this.p=p;
	}
	@Override
	public void run()
	{
		while(true)
		{
			int i=0;
			synchronized(p)
			{
				if(c.getPosition()==0)
				{
			for(i=0;i

你可能感兴趣的:(算法)