Advertisement
Guest User

Customer Class

a guest
Mar 27th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.62 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. /**
  9.  *
  10.  * @author Sven
  11.  */
  12. public class Customer {
  13.     private int customerNumber;
  14.     private int itemNeeded;
  15.     private double avgPickTime;
  16.     private double arriveTime;
  17.     //private boolean getServed;
  18.    
  19.     public Customer(int custNumber, double arrivalTime, int itemsNeeded, double avgPickupTime){
  20.         customerNumber = custNumber;
  21.         arriveTime = arrivalTime;
  22.         itemNeeded = itemsNeeded;
  23.         avgPickTime = avgPickupTime;
  24.      //   getServed = false;
  25.     }
  26.    
  27.     public int getCustNum(){
  28.         return customerNumber;
  29.     }
  30.    
  31.     public double getArrivalTime(){
  32.         return arriveTime;
  33.     }
  34.    
  35.     public double calcShopTime(){
  36.         double shoptime;
  37.         shoptime = avgPickTime * itemNeeded;
  38.         return shoptime;
  39.     }
  40.    
  41.     public double calcFinishTime(){
  42.         double finishtime;
  43.         finishtime = this.calcShopTime() + arriveTime;
  44.         return finishtime;
  45.     }
  46.    
  47.     //basically takes time from getServed = True minus finishtime
  48.     public double calcWaitTime(){
  49.         double waittime;
  50.         waittime = CheckoutLane.calcCheckoutTime()-this.calcFinishTime();
  51.         return waittime;
  52.     }
  53.    
  54.     public double calcEndCheckout(){
  55.         double endcheck;
  56.         endcheck = this.calcFinishTime() + CheckoutLane.calcCheckoutTime();
  57.         return endcheck;
  58.     }
  59.    
  60.     ///returns the shortest lane (based on available express or no)
  61.     public int findShortestLane(){
  62.         int lowestlanelength = 100;
  63.         int lowestlanenumber = 0;
  64.         if(this.itemNeeded <= 12){
  65.             for(CheckoutLane.getLaneType()=="express"){
  66.                 if(CheckoutLane.getCurLength()<lowestlanelength){
  67.                     lowestlanelength =  CheckoutLane.getCurLength();
  68.                     lowestlanenumber = CheckoutLane.getLaneNumber();
  69.                 }        
  70.             }
  71.         }
  72.         else{
  73.             for(CheckoutLane.getLaneType()=="regular"){
  74.                 if(CheckoutLane.getCurLength()<lowestlanelength){
  75.                     lowestlanelength =  CheckoutLane.getCurLength();
  76.                     lowestlanenumber = CheckoutLane.getLaneNumber();
  77.                 }        
  78.             }
  79.         }
  80.         return lowestlanenumber;
  81.     }
  82.    
  83.     public void enterLane(){
  84.         CheckoutLane.addCust(this);
  85.     }
  86.    
  87.     public int getNumItems(){
  88.         return this.itemNeeded;
  89.     }
  90.    
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement