Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
lm-challenge
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Javier Hernández
lm-challenge
Commits
856ad7b7
Commit
856ad7b7
authored
Oct 17, 2019
by
Javier Hernández
🤓
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Output3 test and data classes corrections
- Added output3 test - pharma property corrected for testing acceptation
parent
49f3d4bf
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
11 deletions
+55
-11
PillsBuilder.kt
...lib/src/main/kotlin/com/lm/sales/builders/PillsBuilder.kt
+1
-1
Medicals.kt
...b/src/main/kotlin/com/lm/sales/model/medicals/Medicals.kt
+1
-1
Pills.kt
...-lib/src/main/kotlin/com/lm/sales/model/medicals/Pills.kt
+1
-1
TaxesCalculator.kt
...-lib/src/main/kotlin/com/lm/sales/util/TaxesCalculator.kt
+1
-1
ShoppingTests.kt
lm-challenge-lib/src/test/kotlin/shopping/ShoppingTests.kt
+51
-7
No files found.
lm-challenge-lib/src/main/kotlin/com/lm/sales/builders/PillsBuilder.kt
View file @
856ad7b7
...
@@ -6,7 +6,7 @@ import com.lm.sales.model.medicals.Pills
...
@@ -6,7 +6,7 @@ import com.lm.sales.model.medicals.Pills
class
PillsBuilder
{
class
PillsBuilder
{
private
lateinit
var
name
:
String
private
lateinit
var
name
:
String
private
lateinit
var
pharma
:
String
private
var
pharma
:
String
?
=
null
private
lateinit
var
presentation
:
Presentation
private
lateinit
var
presentation
:
Presentation
private
var
isImported
:
Boolean
=
false
private
var
isImported
:
Boolean
=
false
private
var
basePrice
:
Double
=
0.0
private
var
basePrice
:
Double
=
0.0
...
...
lm-challenge-lib/src/main/kotlin/com/lm/sales/model/medicals/Medicals.kt
View file @
856ad7b7
...
@@ -3,5 +3,5 @@ package com.lm.sales.model.medicals
...
@@ -3,5 +3,5 @@ package com.lm.sales.model.medicals
import
com.lm.sales.model.Product
import
com.lm.sales.model.Product
interface
Medicals
:
Product
{
interface
Medicals
:
Product
{
val
pharma
:
String
val
pharma
:
String
?
}
}
\ No newline at end of file
lm-challenge-lib/src/main/kotlin/com/lm/sales/model/medicals/Pills.kt
View file @
856ad7b7
...
@@ -4,7 +4,7 @@ import com.lm.sales.model.Presentation
...
@@ -4,7 +4,7 @@ import com.lm.sales.model.Presentation
import
com.lm.sales.model.Taxes
import
com.lm.sales.model.Taxes
data class
Pills
(
override
val
name
:
String
,
data class
Pills
(
override
val
name
:
String
,
override
val
pharma
:
String
,
override
val
pharma
:
String
?
=
null
,
override
val
imported
:
Boolean
,
override
val
imported
:
Boolean
,
override
val
basePrice
:
Double
,
override
val
basePrice
:
Double
,
override
val
presentation
:
Presentation
?,
override
val
presentation
:
Presentation
?,
...
...
lm-challenge-lib/src/main/kotlin/com/lm/sales/util/TaxesCalculator.kt
View file @
856ad7b7
...
@@ -41,7 +41,7 @@ class TaxesCalculator {
...
@@ -41,7 +41,7 @@ class TaxesCalculator {
// kotlin's round rounds automatically
// kotlin's round rounds automatically
return
Taxes
().
apply
{
return
Taxes
().
apply
{
taxesAmount
=
round
(
taxes
)
taxesAmount
=
round
(
taxes
)
afterTaxesAmount
=
round
(
product
.
basePrice
.
plus
(
taxes
)
)
afterTaxesAmount
=
product
.
basePrice
.
plus
(
taxesAmount
)
}
}
}
}
...
...
lm-challenge-lib/src/test/kotlin/shopping/ShoppingTests.kt
View file @
856ad7b7
...
@@ -18,7 +18,6 @@ class ShoppingTests {
...
@@ -18,7 +18,6 @@ class ShoppingTests {
// Builds book from input 1 an calculates taxes
// Builds book from input 1 an calculates taxes
val
book
=
BookBuilder
().
withName
(
"book"
)
val
book
=
BookBuilder
().
withName
(
"book"
)
.
isImported
(
false
)
.
withBasePrice
(
12.49
)
.
withBasePrice
(
12.49
)
.
build
().
apply
{
.
build
().
apply
{
taxes
=
TaxesCalculator
.
calculate
(
this
)
taxes
=
TaxesCalculator
.
calculate
(
this
)
...
@@ -26,7 +25,6 @@ class ShoppingTests {
...
@@ -26,7 +25,6 @@ class ShoppingTests {
// Builds CD from input 1 and calculates taxes
// Builds CD from input 1 and calculates taxes
val
cd
=
CDBuilder
().
withName
(
"music CD"
)
val
cd
=
CDBuilder
().
withName
(
"music CD"
)
.
isImported
(
false
)
.
withBasePrice
(
14.99
)
.
withBasePrice
(
14.99
)
.
build
().
apply
{
.
build
().
apply
{
taxes
=
TaxesCalculator
.
calculate
(
this
)
taxes
=
TaxesCalculator
.
calculate
(
this
)
...
@@ -53,7 +51,7 @@ class ShoppingTests {
...
@@ -53,7 +51,7 @@ class ShoppingTests {
fun
input2
(){
fun
input2
(){
// Builds chocolates box from input2 and calculate taxes
// Builds chocolates box from input2 and calculate taxes
val
c
hocoBox
=
ChocolatesBuilder
().
withName
(
"chocolates"
)
val
importedC
hocoBox
=
ChocolatesBuilder
().
withName
(
"chocolates"
)
.
withPresentation
(
Presentation
.
box
)
.
withPresentation
(
Presentation
.
box
)
.
isImported
(
true
)
.
isImported
(
true
)
.
withBasePrice
(
10.00
)
.
withBasePrice
(
10.00
)
...
@@ -62,7 +60,7 @@ class ShoppingTests {
...
@@ -62,7 +60,7 @@ class ShoppingTests {
}
}
// Builds bottle of perfume from input2 and calculate taxes
// Builds bottle of perfume from input2 and calculate taxes
val
p
erfume
=
PerfumeBuilder
().
withName
(
"perfume"
)
val
importedP
erfume
=
PerfumeBuilder
().
withName
(
"perfume"
)
.
withPresentation
(
Presentation
.
bottle
)
.
withPresentation
(
Presentation
.
bottle
)
.
isImported
(
true
)
.
isImported
(
true
)
.
withBasePrice
(
47.50
)
.
withBasePrice
(
47.50
)
...
@@ -71,13 +69,59 @@ class ShoppingTests {
...
@@ -71,13 +69,59 @@ class ShoppingTests {
}
}
val
cart
=
Cart
().
apply
{
val
cart
=
Cart
().
apply
{
productList
.
add
(
c
hocoBox
)
productList
.
add
(
importedC
hocoBox
)
productList
.
add
(
p
erfume
)
productList
.
add
(
importedP
erfume
)
}
}
// Adds cart products to recipe and prints it
// Adds cart products to recipe and prints it
RecipeBuilder
().
withProducts
(
cart
.
productList
).
withRecipeName
(
"Output 2:"
).
printRecipe
()
RecipeBuilder
().
withProducts
(
cart
.
productList
).
withRecipeName
(
"Output 2:"
).
printRecipe
()
}
}
@Test
fun
input3
(){
// Builds importeds bottle of perfume from input3 and calculate taxes
val
importedPerfume
=
PerfumeBuilder
().
withName
(
"perfume"
)
.
withPresentation
(
Presentation
.
bottle
)
.
isImported
(
true
)
.
withBasePrice
(
27.99
)
.
build
().
apply
{
taxes
=
TaxesCalculator
.
calculate
(
this
)
}
// Builds bottle of perfume from input3 and calculate taxes
val
perfume
=
PerfumeBuilder
().
withName
(
"perfume"
)
.
withPresentation
(
Presentation
.
bottle
)
.
withBasePrice
(
18.99
)
.
build
().
apply
{
taxes
=
TaxesCalculator
.
calculate
(
this
)
}
// Builds packet of headache pills from input3 and calculate taxes
val
pills
=
PillsBuilder
().
withName
(
"headache pills"
)
.
withPresentation
(
Presentation
.
packet
)
.
withBasePrice
(
9.75
)
.
build
().
apply
{
taxes
=
TaxesCalculator
.
calculate
(
this
)
}
// Builds box of imported chocolates from input3 and calculate taxes
val
importedChocoBox
=
ChocolatesBuilder
().
withName
(
"chocolates"
)
.
withPresentation
(
Presentation
.
box
)
.
isImported
(
true
)
.
withBasePrice
(
11.25
)
.
build
().
apply
{
taxes
=
TaxesCalculator
.
calculate
(
this
)
}
val
cart
=
Cart
().
apply
{
productList
.
add
(
importedPerfume
)
productList
.
add
(
perfume
)
productList
.
add
(
pills
)
productList
.
add
(
importedChocoBox
)
}
// Adds cart products to recipe and prints it
RecipeBuilder
().
withProducts
(
cart
.
productList
).
withRecipeName
(
"Output 3:"
).
printRecipe
()
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment