<commit_before>package city.transportation;

import java.awt.Dimension;
import java.util.List;
import java.util.concurrent.Semaphore;

import city.Place;
import city.market.Market;
import city.market.MarketCashierRole;
import city.restaurant.Restaurant;
import city.restaurant.RestaurantCookRole;
import city.restaurant.yixin.YixinCookRole;
import city.transportation.gui.BusAgentGui;
import city.market.Item;

public class TruckAgent {
	List<Package> packages;
	Semaphore isMoving;
	Market _market;
	BusAgentGui gui;
	Boolean out = false;

	enum packageState{inTruck, delivering, unloaded, done};

	class Package{
	    List<Item> _items;
	    Restaurant _restaurant;
	    int orderId;
	    double bill;
	    packageState pState = packageState.inTruck;
	    
	    Package(List<Item> items, Restaurant restaurant){
	    	_items=items;
	    	_restaurant = restaurant;
	    	
	    }
	}
	
	//Constructor
	TruckAgent(Market market){
		_market = market;
	}
	
	//----------------------------------------------Messages------------------------------------------
	public void msgHereAreGoodsForDelivery(List<Item> items, Restaurant restaurant){
	    packages.add(new Package(items, restaurant));
	}
	
	public void msgAtDestination(){
	    isMoving.release();
	}

	public void msgGoodsUnloaded(int order_id){
	    for(Package aPackage : packages){
	        if(aPackage.orderId == order_id){
	        aPackage.pState = packageState.unloaded;}
	    }
	}

	public void msgAtMarket(){
	    isMoving.release();
	}
	
	//----------------------------------------------Scheduler------------------------------------------
	public boolean pickAndExecuteAnAction(){
		for(Package temp: packages){
			if(temp.pState == packageState.unloaded){
				RemoveFromList(temp);
				return true;
			}
			
			if(temp.pState == packageState.inTruck){
				DeliverToDestination(temp);
				return true;
			}
			
		}
		
		if(packages.isEmpty() && out == true){
			GoBackToMarket();
			return true;
		}
        
		return false;
	}
	
	//----------------------------------------------Actions------------------------------------------
	public void DeliverToDestination(Package aPackage){
		out = true;
		aPackage.pState = packageState.delivering;
		gui.goToDestination(aPackage._restaurant);
		isMoving.acquire();
		aPackage.cook.msgOrderDelivered(aPackage._items, _market);
	}

	public void RemoveFromList(Package aPackage){
		packages.remove(aPackage);
	}

	public void GoBackToMarket(){
	    out = false;
	    gui.goToMarket(_market);
	    isMoving.acquire();
	    _market.MarketCashier.msgBackFromRun(this);
	}
}
<commit_msg>Change Cook Messaging From Truck<commit_after>package city.transportation;

import java.awt.Dimension;
import java.util.List;
import java.util.concurrent.Semaphore;

import city.Place;
import city.market.Market;
import city.market.MarketCashierRole;
import city.restaurant.Restaurant;
import city.restaurant.RestaurantCookRole;
import city.restaurant.yixin.YixinCookRole;
import city.transportation.gui.BusAgentGui;
import city.market.Item;

public class TruckAgent {
	List<Package> packages;
	Semaphore isMoving;
	Market _market;
	BusAgentGui gui;
	Boolean out = false;

	enum packageState{inTruck, delivering, unloaded, done};

	class Package{
	    List<Item> _items;
	    Restaurant _restaurant;
	    int orderId;
	    double bill;
	    packageState pState = packageState.inTruck;
	    
	    Package(List<Item> items, Restaurant restaurant){
	    	_items=items;
	    	_restaurant = restaurant;
	    	
	    }
	}
	
	//Constructor
	TruckAgent(Market market){
		_market = market;
	}
	
	//----------------------------------------------Messages------------------------------------------
	public void msgHereAreGoodsForDelivery(List<Item> items, Restaurant restaurant){
	    packages.add(new Package(items, restaurant));
	}
	
	public void msgAtDestination(){
	    isMoving.release();
	}

	public void msgGoodsUnloaded(int order_id){
	    for(Package aPackage : packages){
	        if(aPackage.orderId == order_id){
	        aPackage.pState = packageState.unloaded;}
	    }
	}

	public void msgAtMarket(){
	    isMoving.release();
	}
	
	//----------------------------------------------Scheduler------------------------------------------
	public boolean pickAndExecuteAnAction(){
		for(Package temp: packages){
			if(temp.pState == packageState.unloaded){
				RemoveFromList(temp);
				return true;
			}
			
			if(temp.pState == packageState.inTruck){
				DeliverToDestination(temp);
				return true;
			}
			
		}
		
		if(packages.isEmpty() && out == true){
			GoBackToMarket();
			return true;
		}
        
		return false;
	}
	
	//----------------------------------------------Actions------------------------------------------
	public void DeliverToDestination(Package aPackage){
		out = true;
		aPackage.pState = packageState.delivering;
		gui.goToDestination(aPackage._restaurant);
		isMoving.acquire();
		aPackage._restaurant.Cook.msgOrderFulfillment(_market, aPackage._items);
	}

	public void RemoveFromList(Package aPackage){
		packages.remove(aPackage);
	}

	public void GoBackToMarket(){
	    out = false;
	    gui.goToMarket(_market);
	    isMoving.acquire();
	    _market.MarketCashier.msgBackFromRun(this);
	}
}

{'fraction_non_alphanumeric': 0.1954641552950221, 'fraction_numerical': 0.0, 'mean_word_length': 2.4463576158940397, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2967804', 'n_tokens_mistral': 1722, 'n_tokens_neox': 1495, 'n_words': 300}