Разработка иерархии классов и интерфейсов для предметной области "Напитки", страница 7

return i;

}

}

return -1;

}

}

public class Supplier implements Serializable{

/** Supplier address */

private int _addressID;

/** Supplier id */

private int _id;

/** The name of the supplier */

private String _name;

/** Supplier phone */

private String _phone;

public Supplier(String name, String phone, int addressID, int id){

_name = name;

_phone = phone;

_addressID = addressID;

_id = id;

}

/** Get supplier address */

public int getAddressID(){

return this._addressID;

}

/** Get supplier name */

public String getName(){

return this._name;

}

/** Get supplier phone */

public String getPhone(){

return this._phone;

}

/** Get supplier id */

public int getID(){

return this._id;

}

}

public class SupplierManager implements Serializable{

private ArrayList<Supplier> _suppliers;

/** delete */

int last_id = 0;

public int getLastID(){

return last_id;

}

/** delete */

public SupplierManager(){

_suppliers = new ArrayList<Supplier>();

}

public void Add(String name, String phone, int addressID){

_suppliers.add(new Supplier(name, phone, addressID, last_id));

/** delete */

last_id++;

/** delete */

}

/** Get supplier address */

public int getAddressID(int index){

return this._suppliers.get(index).getAddressID();

}

/** Get supplier name */

public String getName(int index){

return this._suppliers.get(index).getName();

}

/** Get supplier phone */

public String getPhone(int index){

return this._suppliers.get(index).getPhone();

}

/** Get supplier id */

public int getID(int index){

return this._suppliers.get(index).getID();

}

public int getLength(){

return this._suppliers.size();

}

public int getIndexByID(int id){

for(int i = 0; i < _suppliers.size(); i++){

if(_suppliers.get(i).getID() == id){

return i;

}

}

return -1;

}

}

public class Warehouse implements Serializable{

private int _id;

/** Wholesale price of the one portion */

private float _wholesalePrice;

/** servings of stock */

private int _inStock;

/** goods been sold */

private int _beenSold;

public Warehouse(float wholesalePrice, int inStock, int beenSold, int id){

_wholesalePrice = wholesalePrice;

_inStock = inStock;

_beenSold = beenSold;

_id = id;

}

public float getWholesalePrice(){

return this._wholesalePrice;

}

public int getInStock(){

return this._inStock;

}

public int getBeenSold(){

return this._beenSold;

}

public int getID(){

return this._id;

}

}

public class WarehouseManager implements Serializable{

private ArrayList<Warehouse> _warehouses;

/** delete */

int last_id = 0;

public int getLastID(){

return last_id;

}

public WarehouseManager(){

_warehouses = new ArrayList<Warehouse>();

}

public void Add(float wholesalePrice, int inStock, int beenSold){

_warehouses.add(new Warehouse(wholesalePrice, inStock, beenSold, last_id));

/** delete */

last_id++;

/** delete */

}

public float getWholesalePrice(int index){

return this._warehouses.get(index).getWholesalePrice();

}

public int getInStock(int index){

return this._warehouses.get(index).getInStock();

}

public int getBeenSold(int index){

return this._warehouses.get(index).getBeenSold();

}

public int getID(int index){

return this._warehouses.get(index).getID();

}

public void DeleteWarehouse(int id){

for(int i = 0; i < _warehouses.size(); i++){

if(_warehouses.get(i).getID() == id){

// Drop(_portions.get(i).getID());

_warehouses.remove(i);

break;

}

}

}

public int getIndexByID(int id){

for(int i = 0; i < _warehouses.size(); i++){

if(_warehouses.get(i).getID() == id){

return i;

}

}

return -1;

}

}