Advertisement
Guest User

CheckoutLane

a guest
Mar 27th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.72 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package project4checkoutsim;
  7.  
  8. import java.util.*;
  9. /**
  10.  *
  11.  * @author Sven
  12.  */
  13. public class CheckoutLane {
  14.     private int laneNumber;
  15.     private String laneType;
  16.     private double timePerItem;
  17.     private double payProcTime;
  18.    
  19.     private int custServed;
  20.     private int maxLength;
  21.     private boolean cashIsIdle;
  22.     //private int curLength;
  23.     private double averageQueueLength;
  24.     private double averageWaitTime;
  25.    
  26.     private Queue<Customer> coQueue;
  27.    
  28.    
  29.     public CheckoutLane(int lanNumber, String lanType, double timPerItem, double payProcesTime){
  30.         Queue<Customer> coQueue = new LinkedList<>();
  31.        
  32.         laneNumber = lanNumber;
  33.         laneType = lanType;
  34.         timePerItem = timPerItem;
  35.         payProcTime = payProcesTime;        
  36.        
  37.         custServed = 0;
  38.         maxLength = 0;
  39.         cashIsIdle = true;
  40.         //curLength = 0;
  41.         averageQueueLength = 0.0;
  42.         averageWaitTime = 0.0;
  43.     }
  44.    
  45.     public void cashSetState(){
  46.         if(this.cashIsIdle == true){
  47.             this.cashIsIdle = false;
  48.         }
  49.         else{
  50.             this.cashIsIdle = true;
  51.         }
  52.     }
  53.    
  54.     //Uses SimClock I think, leave alone for now
  55.     //Actually may want to split in to getAvgWait and setAvgWait
  56.     public double calcAvgWait(){
  57.         return averageWaitTime;
  58.     }
  59.    
  60.     public int getMaxLength(){
  61.         return this.maxLength;
  62.     }
  63.    
  64.     public void addCust(Customer cust){
  65.         coQueue.add(cust);
  66.         if(coQueue.size()>this.getMaxLength()){
  67.             this.maxLength = coQueue.size();
  68.         }
  69.     }
  70.    
  71.     //May be incorrect, depends how the list will work. Since it's LinkedList,
  72.     //may be implemented wrong and removes from END of list.
  73.     public void removeCust(){
  74.         coQueue.remove();
  75.         this.custServed++;
  76.     }
  77.    
  78.     public int getServed(){
  79.         //System.out.println("DAAAAAAAAAAAAAAAMMMMMMMMMN YOU GOT SERVED");
  80.         return this.custServed;
  81.     }
  82.    
  83.     public double calcCheckoutTime(){
  84.         double checkouttime;
  85.         checkouttime = (this.payProcTime * Customer.getNumItems()) + this.payProcTime;
  86.         return checkouttime;
  87.     }
  88.    
  89.     public String getLaneType(){
  90.         return this.laneType;
  91.     }
  92.    
  93.     //returns true if idle, false if busy
  94.     public boolean getCashState(){
  95.         return this.cashIsIdle;
  96.     }
  97.    
  98.     public int getCurLength(){
  99.         return coQueue.size();
  100.     }
  101.    
  102.     public int getLaneNumber(){
  103.         return this.laneNumber;
  104.     }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement