-
Notifications
You must be signed in to change notification settings - Fork 1
/
Customer.java
68 lines (60 loc) · 1.9 KB
/
Customer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* A class that extends Person.
* @author Eylul Badem
* @version 08.03.2021
*/
public class Customer extends Person
{
// properties
String content = "none";
Item currentItem = new Item( 0, content );
// constructor
public Customer( String name)
{
super(name);
}
// methods
public Item getCurrentItem()
{
return currentItem;
}
public void setCurrentItem( Item currentItem )
{
this.currentItem.weight = currentItem.getW();
this.currentItem.content = currentItem.getC();
}
/**
* This method sends the wanted item to the wanted customer.
* @param company the company the program is working with, @param item the item to send, @param receiver receiver customer
*/
public void sendItem( Company company, Item item, Customer receiver)
{
boolean available;
available = false;
Customer sender = new Customer( this.name );
for ( int i = 0; i < company.employees.length; i++ )
{
if ( company.employees[i] != null )
{
if ( company.employees[i].getAvailability() )
available = true;
}
}
if ( available )
{
company.createDeliverable( item, sender, receiver);
receiver.setCurrentItem( item );
System.out.println( "Item added to queue." );
}
else
System.out.println( "Your employees are not available." );
}
public String toString()
{
Item emptyItem = new Item( 0, content );
if ( currentItem == emptyItem )
return "Customer= name:" + this.name + " and current item: none ";
else
return "Customer= name:" + this.name + " and current item:" + currentItem.toString();
}
}