File tree Expand file tree Collapse file tree 3 files changed +25
-10
lines changed
examples/java/java-booking-02_introduce_parameter_object/src
main/java/tv/codely/booking
test/java/tv/codely/booking Expand file tree Collapse file tree 3 files changed +25
-10
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,7 @@ public Booking(
2020 DateRange bookingDateRange ,
2121 Customer customer ,
2222 BookingType bookingType ,
23- DiscountType discountType ,
24- DiscountValue discountValue ,
23+ Discount discount ,
2524 TaxType taxType ,
2625 TaxValue taxValue
2726 ) {
@@ -32,8 +31,8 @@ public Booking(
3231 this .customerName = customer .name ();
3332 this .customerEmail = customer .emailAddress ();
3433 this .bookingType = bookingType ;
35- this .discountType = discountType ;
36- this .discountValue = discountValue ;
34+ this .discountType = discount . type () ;
35+ this .discountValue = discount . value () ;
3736 this .taxType = taxType ;
3837 this .taxValue = taxValue ;
3938 }
Original file line number Diff line number Diff line change 1+ package tv .codely .booking ;
2+
3+ public final class Discount {
4+ private final DiscountType type ;
5+ private final DiscountValue value ;
6+
7+ public Discount (DiscountType type , DiscountValue value ) {
8+ this .type = type ;
9+ this .value = value ;
10+ }
11+
12+ public DiscountType type () {
13+ return type ;
14+ }
15+
16+ public DiscountValue value () {
17+ return value ;
18+ }
19+ }
Original file line number Diff line number Diff line change @@ -23,8 +23,7 @@ void get_the_correct_status_when_the_booking_has_not_started_yet() {
2323 new EmailAddress ("perico.los.palotes@mail.com" )
2424 ),
2525 BookingType .VACATION ,
26- DiscountType .NONE ,
27- new DiscountValue (0 ),
26+ new Discount (DiscountType .NONE , new DiscountValue (0 )),
2827 TaxType .NONE ,
2928 new TaxValue (0 )
3029 );
@@ -48,8 +47,7 @@ void get_the_correct_status_when_the_booking_is_currently_active() {
4847 new EmailAddress ("perico.los.palotes@mail.com" )
4948 ),
5049 BookingType .VACATION ,
51- DiscountType .NONE ,
52- new DiscountValue (0 ),
50+ new Discount (DiscountType .NONE , new DiscountValue (0 )),
5351 TaxType .NONE ,
5452 new TaxValue (0 )
5553 );
@@ -73,8 +71,7 @@ void get_the_correct_status_when_the_booking_is_finished() {
7371 new EmailAddress ("perico.los.palotes@mail.com" )
7472 ),
7573 BookingType .VACATION ,
76- DiscountType .NONE ,
77- new DiscountValue (0 ),
74+ new Discount (DiscountType .NONE , new DiscountValue (0 )),
7875 TaxType .NONE ,
7976 new TaxValue (0 )
8077 );
You can’t perform that action at this time.
0 commit comments