-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDistributor.java
More file actions
78 lines (65 loc) · 2.12 KB
/
Distributor.java
File metadata and controls
78 lines (65 loc) · 2.12 KB
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
69
70
71
72
73
74
75
76
77
78
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
/**
*
* @author shahad
*/
public class Distributor extends Account {
protected boolean deliveryStatus;
protected Date dateOfDel;
public static int numOfDistru;
protected double deliveryfee;
public Distributor() {
}
public Distributor(boolean deliveryStatus, double deliveryfee) {
this.deliveryStatus = deliveryStatus;
this.deliveryfee = deliveryfee;
numOfDistru++;
}
public Distributor(String username, String name, String password, String phone_no, String address) {
super(username, name, password, phone_no, address);
}
//Calculate the delivery fees
public void Deliveryfee (double distance)
{
if (distance == 0)
{
//If customer do not want to deliver the order
deliveryfee = 0.0;
System.out.println("There is no delivery fee.");
}
else if (distance > 1)
{
deliveryfee = ((distance * 0.5) + 2.0);
System.out.println("Your delivery fee is: $" + deliveryfee);
}
else if (distance < 0) {
System.out.println("Invalid input");
}
}
public void setDeliveryStatus() {
Scanner input = new Scanner(System.in);
System.out.println("Did the customer receive his order? (if yes enter 1, if no enter zero)");
int no= input.nextInt();
if(no==1){
deliveryStatus=true;
}
else if (no==0){
deliveryStatus=false;
}
}
public void delivaryConf(){
//Print out the delivery status
if(deliveryStatus){
System.out.println("The order has been delivered to the customer successfully");
System.out.print("Date and time of the delivery: ");
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
dateOfDel = new Date();
System.out.println(dateFormat.format(dateOfDel));
}
else if(!deliveryStatus)
System.out.println("order has not been delivered");
}
}