-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTruck.java
68 lines (58 loc) · 2.09 KB
/
Truck.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
package it.uniud.poo.trasporti_2024;
import lombok.Getter;
import lombok.NonNull;
/**
* MISSION: to represent a truck that can be used to transport goods.
* the truck has an id, a type (e.g. "van", "truck", "train") and a cost multiplier. it is immutable.
* The cost multiplier is used to compute the cost of a path, and is applied to the basic cost of each leg.
*/
public class Truck {
private final @Getter String id;
private final @Getter String type;
private @Getter double costMultiplier = 1.0;
// Constructor, getters, and setters
public Truck(@NonNull String id, @NonNull String type, double costMultiplier) {
if (id.isEmpty() || type.isEmpty()) {
throw new IllegalArgumentException("id and type should not be empty");
}
this.id = id;
this.type = type;
this.costMultiplier = costMultiplier;
}
/**
* Creates a truck with the given id and type.
*
* @param id the id of the truck, not null and not empty
* @param type the type of the truck, not null and not empty
* @throws IllegalArgumentException if id or type are null or empty
*/
public Truck(@NonNull String id, @NonNull String type) {
if (id.isEmpty() || type.isEmpty()) {
throw new IllegalArgumentException("id and type should not be empty");
}
this.id = id;
this.type = type;
}
/**
* @param cost the basic cost of a leg
* @return the cost of the leg, which is the basic cost multiplied by the cost multiplier of the truck.
*/
public double applyCostMultiplier(double cost) {
return cost * costMultiplier;
}
/**
* @param goodsKind
* @param goodsQuantity
* @return true if the truck is suitable for transporting the given goods kind and quantity
*/
public boolean isSuitableForGoods(GoodsKind goodsKind, double goodsQuantity) {
// TODO: implement this method
return false;
}
public TruckStatus getStatus() {
return null;
}// TODO
public int getKilometersRunThisMonth() { // TODO
return 0;
}
}