Skip to content

Commit 6055e1b

Browse files
nprycedmcg
authored andcommitted
open-to-sealed.1 : move classes to same source file
1 parent 80313cd commit 6055e1b

File tree

5 files changed

+98
-128
lines changed

5 files changed

+98
-128
lines changed

src/main/java/travelator/itinerary/Accommodation.kt

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/main/java/travelator/itinerary/Attraction.kt

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,109 @@
11
package travelator.itinerary
22

33
import travelator.Id
4-
import travelator.geo.MapOverlay
4+
import travelator.Location
5+
import travelator.geo.*
56
import travelator.money.Money
7+
import java.time.Duration
8+
import java.time.Period
9+
import java.time.ZonedDateTime
610

711
interface ItineraryItem {
812
val id: Id<ItineraryItem>
913
val description: String
1014
val costs: List<Money>
1115
val mapOverlay: MapOverlay
16+
}
17+
18+
data class Accommodation(
19+
override val id: Id<Accommodation>,
20+
val location: Location,
21+
val checkInFrom: ZonedDateTime,
22+
val checkOutBefore: ZonedDateTime,
23+
val pricePerNight: Money
24+
) : ItineraryItem {
25+
val nights = Period.between(checkInFrom.toLocalDate(), checkOutBefore.toLocalDate()).days
26+
val totalPrice: Money = pricePerNight * nights
27+
28+
override val description
29+
get() = "$nights nights at ${location.userReadableName}"
30+
override val costs
31+
get() = listOf(totalPrice)
32+
override val mapOverlay
33+
get() = PointOverlay(
34+
id = id,
35+
position = location.position,
36+
text = location.userReadableName,
37+
icon = StandardIcons.HOTEL
38+
)
39+
40+
}
41+
42+
data class Attraction(
43+
override val id: Id<Attraction>,
44+
val location: Location,
45+
val notes: String
46+
) : ItineraryItem {
47+
override val description get() =
48+
location.userReadableName
49+
50+
override val costs get() =
51+
emptyList<Money>()
52+
53+
override val mapOverlay get() =
54+
PointOverlay(
55+
position = location.position,
56+
text = description,
57+
icon = StandardIcons.ATTRACTION,
58+
id = id
59+
)
60+
61+
}
62+
63+
data class Journey(
64+
override val id: Id<Journey>,
65+
val travelMethod: TravelMethod,
66+
val departsFrom: Location,
67+
val departureTime: ZonedDateTime,
68+
val arrivesAt: Location,
69+
val arrivalTime: ZonedDateTime,
70+
val price: Money,
71+
val path: List<Position> = listOf(departsFrom.position, arrivesAt.position),
72+
) : ItineraryItem {
73+
override val description
74+
get() = "${departsFrom.userReadableName} " +
75+
"to ${arrivesAt.userReadableName} " +
76+
"by ${travelMethod.userReadableName}"
77+
78+
override val costs
79+
get() = listOf(price)
80+
81+
override val mapOverlay
82+
get() = OverlayGroup(
83+
id = id,
84+
elements = listOf(
85+
PathOverlay(path, travelMethod.userReadableName),
86+
PointOverlay(departsFrom.position, departsFrom.userReadableName, StandardIcons.START),
87+
PointOverlay(arrivesAt.position, arrivesAt.userReadableName, StandardIcons.END)
88+
)
89+
)
90+
91+
}
92+
93+
data class RestaurantBooking(
94+
override val id: Id<RestaurantBooking>,
95+
val location: Location,
96+
val time: ZonedDateTime
97+
) : ItineraryItem {
98+
override val description get() = location.userReadableName
99+
100+
override val costs get() = emptyList<Money>()
101+
102+
override val mapOverlay get() =
103+
PointOverlay(
104+
id = id,
105+
position = location.position,
106+
text = location.userReadableName,
107+
icon = StandardIcons.RESTAURANT
108+
)
12109
}

src/main/java/travelator/itinerary/Journey.kt

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/main/java/travelator/itinerary/RestaurantBooking.kt

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)