Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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 project4checkoutsim;
- import java.util.*;
- /**
- *
- * @author Sven
- */
- public class CheckoutLane {
- private int laneNumber;
- private String laneType;
- private double timePerItem;
- private double payProcTime;
- private int custServed;
- private int maxLength;
- private boolean cashIsIdle;
- //private int curLength;
- private double averageQueueLength;
- private double averageWaitTime;
- private Queue<Customer> coQueue;
- public CheckoutLane(int lanNumber, String lanType, double timPerItem, double payProcesTime){
- Queue<Customer> coQueue = new LinkedList<>();
- laneNumber = lanNumber;
- laneType = lanType;
- timePerItem = timPerItem;
- payProcTime = payProcesTime;
- custServed = 0;
- maxLength = 0;
- cashIsIdle = true;
- //curLength = 0;
- averageQueueLength = 0.0;
- averageWaitTime = 0.0;
- }
- public void cashSetState(){
- if(this.cashIsIdle == true){
- this.cashIsIdle = false;
- }
- else{
- this.cashIsIdle = true;
- }
- }
- //Uses SimClock I think, leave alone for now
- //Actually may want to split in to getAvgWait and setAvgWait
- public double calcAvgWait(){
- return averageWaitTime;
- }
- public int getMaxLength(){
- return this.maxLength;
- }
- public void addCust(Customer cust){
- coQueue.add(cust);
- if(coQueue.size()>this.getMaxLength()){
- this.maxLength = coQueue.size();
- }
- }
- //May be incorrect, depends how the list will work. Since it's LinkedList,
- //may be implemented wrong and removes from END of list.
- public void removeCust(){
- coQueue.remove();
- this.custServed++;
- }
- public int getServed(){
- //System.out.println("DAAAAAAAAAAAAAAAMMMMMMMMMN YOU GOT SERVED");
- return this.custServed;
- }
- public double calcCheckoutTime(){
- double checkouttime;
- checkouttime = (this.payProcTime * Customer.getNumItems()) + this.payProcTime;
- return checkouttime;
- }
- public String getLaneType(){
- return this.laneType;
- }
- //returns true if idle, false if busy
- public boolean getCashState(){
- return this.cashIsIdle;
- }
- public int getCurLength(){
- return coQueue.size();
- }
- public int getLaneNumber(){
- return this.laneNumber;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement