-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShipmentMethod.java
More file actions
54 lines (39 loc) · 1.42 KB
/
ShipmentMethod.java
File metadata and controls
54 lines (39 loc) · 1.42 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
import java.util.Scanner;
public interface ShipmentMethod {
double calculateShipping(double totalWeight);
}
class StandardShipment implements ShipmentMethod {
public double calculateShipping(double totalWeight) {
return totalWeight * 1.0;
}
}
class ExpressShipment implements ShipmentMethod {
public double calculateShipping(double totalWeight) {
return totalWeight * 1.5;
}
}
class SpeciaShipment implements ShipmentMethod{
Scanner scanner = new Scanner(System.in);
System.out.println("Please enter your note for special express: ")
String usernote = scanner.nextline();
System.out.println("###\n" + usernote + "###")
public double calculateShipping(double totalWeight){
}
}
public class Shipment {
private String address;
private ShipmentMethod shipmentMethod;
public Shipment(String address, ShipmentMethod shipmentMethod) {
this.address = address;
this.shipmentMethod = shipmentMethod;
}
// Adresi ekrana verme
public void displayShippingInfo() {
System.out.println("Gönderim adresi: " + address);
}
// Gönderim maliyetini hesaplama
public double shippingCost(double totalWeight) {
return shipmentMethod.calculateShipping(totalWeight);
System.out.println("Total cost: " + shipmentMethod.calculateShipping(totalWeight));
}
}