шпаргалки
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1018 B

2 years ago
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package gazstation;
import java.util.Random;
/**
*
* @author denis
*/
class FilingColumn {
private int bigTank;
private boolean isOrder;
public FilingColumn (){
bigTank = new Random().nextInt(500);
isOrder = true;
}
public synchronized boolean getFuel(int fuel) {
if(isOrder){
if(bigTank<fuel){
isOrder = false;
GazStation.getState().callGazProducer(this);
return false;
}
bigTank -= fuel;
}
return isOrder;
}
public synchronized void addFuel(int fuel){
bigTank += fuel;
System.out.println("Объем цистерны: " + bigTank + " л.");
isOrder = true;
notifyAll();
}
}