PIbd-14_Antonova_A.A.__Hard/CollectionGenericObjects/AbstractCompany.java

38 lines
1.1 KiB
Java
Raw Permalink Normal View History

2024-06-10 13:56:47 +04:00
package CollectionGenericObjects;
import Drawnings.DrawningTruck;
import java.awt.*;
import java.util.Random;
public class AbstractCompany {
protected int _placeSizeWidth = 120;
protected int _placeSizeHeight = 120;
protected int _pictureWidth;
protected int _pictureHeight;
public ICollectionGenericObjects<DrawningTruck> _collection = null;
private int GetMaxCount (){ return _pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight);}
public AbstractCompany(int picWidth, int picHeight,
ICollectionGenericObjects<DrawningTruck> collection)
{
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = collection;
_collection.SetMaxCount( GetMaxCount(), DrawningTruck.class);
}
public DrawningTruck GetRandomObject()
{
Random random = new Random();
return _collection.Get(random.nextInt(GetMaxCount()));
}
public void DrawBackgound(Graphics g) { }
protected void SetObjectsPosition() { }
public void SetPosition()
{
SetObjectsPosition();
}
}