From ggc
|
001 packagepackage is used to name the directory or folder a class is in intermediate;
002
003 importimport means to make the classes and/or packages available in this program java.util.*;
004
005 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects Cashier
006 {open braces start code blocks and must be matched with a close brace
007 /**items per second*/
008 privateprivate is used to restrict access to the current class only doubledouble is the type for numbers that can contain decimal fractions rateOfChecking;
009
010 /**fast lane is forfor is a looping structure for repeatedly executing a block of code 15 items or less*/
011 privateprivate is used to restrict access to the current class only booleanboolean is a type that is either true or false fastLane;
012
013 privateprivate is used to restrict access to the current class only doubledouble is the type for numbers that can contain decimal fractions nextAvailableTime;
014
015 privateprivate is used to restrict access to the current class only Queue<Customer> queue;
016
017 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer id;
018 privateprivate is used to restrict access to the current class only staticstatic means that an instance is not required for access (class level access) intint is the type for whole numbers and it is short for integer cashiersCreated=this assignment operator makes the left side equal to the right side1;
019
020 publicpublic is used to indicate unrestricted access (any other class can have access) Cashier()
021 {open braces start code blocks and must be matched with a close brace
022 rateOfChecking=this assignment operator makes the left side equal to the right side0.5;
023 fastLane=this assignment operator makes the left side equal to the right sidefalsefalse is a value for the boolean type and means not true;
024 queue=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor LinkedList<Customer>();
025 id=this assignment operator makes the left side equal to the right sidecashiersCreated;
026 cashiersCreated++this is the increment operator, which increases the variable by 1;
027 }close braces end code blocks and must match an earlier open brace
028
029 publicpublic is used to indicate unrestricted access (any other class can have access) booleanboolean is a type that is either true or false hasCustomer(Customer customer)
030 {open braces start code blocks and must be matched with a close brace
031 forfor is a looping structure for repeatedly executing a block of code(Customer c: queue)
032 {open braces start code blocks and must be matched with a close brace
033 ifif executes the next statement only if the condition in parenthesis evaluates to true(c==this is the comparison operator which evaluates to true if both sides are the samecustomer) returnreturn means to provide the result of the method and/or cease execution of the method immediately truetrue is the boolean value that is the opposite of false;
034 }close braces end code blocks and must match an earlier open brace
035 returnreturn means to provide the result of the method and/or cease execution of the method immediately falsefalse is a value for the boolean type and means not true;
036 }close braces end code blocks and must match an earlier open brace
037
038 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value joinLane(Customer customer)
039 {open braces start code blocks and must be matched with a close brace
040 queue.add(customer);
041 }close braces end code blocks and must match an earlier open brace
042
043 publicpublic is used to indicate unrestricted access (any other class can have access) booleanboolean is a type that is either true or false canJoin(Customer customer)
044 {open braces start code blocks and must be matched with a close brace
045 ifif executes the next statement only if the condition in parenthesis evaluates to true(fastLane)
046 returnreturn means to provide the result of the method and/or cease execution of the method immediately customer.getItems()<=this evaluates to true if the left side is not more than the right side15;
047 returnreturn means to provide the result of the method and/or cease execution of the method immediately truetrue is the boolean value that is the opposite of false;
048 }close braces end code blocks and must match an earlier open brace
049
050 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value scanNextCustomer(doubledouble is the type for numbers that can contain decimal fractions startTime)
051 {open braces start code blocks and must be matched with a close brace
052 ifif executes the next statement only if the condition in parenthesis evaluates to true(queue.isEmpty())
053 returnreturn means to provide the result of the method and/or cease execution of the method immediately;
054 ifif executes the next statement only if the condition in parenthesis evaluates to true(startTime<nextAvailableTime)
055 returnreturn means to provide the result of the method and/or cease execution of the method immediately;
056 Customer customer=this assignment operator makes the left side equal to the right sidequeue.remove();
057 intint is the type for whole numbers and it is short for integer items=this assignment operator makes the left side equal to the right sidecustomer.getItems();
058 doubledouble is the type for numbers that can contain decimal fractions timeToProcess=this assignment operator makes the left side equal to the right sideitems/rateOfChecking;
059 customer.setExitLaneTime(startTime+adds two numbers together or concatenates Strings togethertimeToProcess);
060 nextAvailableTime=this assignment operator makes the left side equal to the right sidestartTime+adds two numbers together or concatenates Strings togethertimeToProcess;
061 }close braces end code blocks and must match an earlier open brace
062
063 publicpublic is used to indicate unrestricted access (any other class can have access) doubledouble is the type for numbers that can contain decimal fractions getNextAvailableTime()
064 {open braces start code blocks and must be matched with a close brace
065 returnreturn means to provide the result of the method and/or cease execution of the method immediately nextAvailableTime;
066 }close braces end code blocks and must match an earlier open brace
067
068 publicpublic is used to indicate unrestricted access (any other class can have access) intint is the type for whole numbers and it is short for integer getNumberInQueue()
069 {open braces start code blocks and must be matched with a close brace
070 returnreturn means to provide the result of the method and/or cease execution of the method immediately queue.size();
071 }close braces end code blocks and must match an earlier open brace
072
073 publicpublic is used to indicate unrestricted access (any other class can have access) String toString()
074 {open braces start code blocks and must be matched with a close brace
075 String text=this assignment operator makes the left side equal to the right side"Cashier#"+adds two numbers together or concatenates Strings togetherid+adds two numbers together or concatenates Strings together"[";
076 forfor is a looping structure for repeatedly executing a block of code(Customer c: queue)
077 text+=this increases the variable on the left by the value on the rightc.toString()+adds two numbers together or concatenates Strings together", ";
078 text+=this increases the variable on the left by the value on the right"]";
079 returnreturn means to provide the result of the method and/or cease execution of the method immediately text;
080 }close braces end code blocks and must match an earlier open brace
081
082 publicpublic is used to indicate unrestricted access (any other class can have access) staticstatic means that an instance is not required for access (class level access) voidvoid means the method does not return a value mainThe main method is the place where applications begin executing.(String[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays args)
083 {open braces start code blocks and must be matched with a close brace
084 System.out.println("Cashier comes on duty.");
085 Cashier c=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Cashier();
086 System.out.println(c);
087 Customer cust=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Customer();
088 c.joinLane(cust);
089 System.out.println("A customer joins the lane.");
090 System.out.println(c);
091 Customer cust2=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Customer();
092 c.joinLane(cust2);
093 System.out.println("A customer joins the lane.");
094 System.out.println(c);
095 Customer cust3=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Customer();
096 System.out.println("A customer joins the lane.");
097 c.joinLane(cust3);
098 System.out.println(c);
099 System.out.println("A customer is scanned.");
100 c.scanNextCustomer(5);
101 System.out.println(c);
102 }close braces end code blocks and must match an earlier open brace
103 }close braces end code blocks and must match an earlier open brace
|
Compiler Errors:
----------
1. ERROR in intermediate/Cashier.java (at line 46)
return customer.getItems()<=15;
^^^^^^^^
The method getItems() is undefined for the type Customer
----------
2. ERROR in intermediate/Cashier.java (at line 57)
int items=customer.getItems();
^^^^^^^^
The method setExitLaneTime(double) is undefined for the type Customer
----------
3 problems (3 errors)
Download/View intermediate/Cashier.java