Académique Documents
Professionnel Documents
Culture Documents
YouworkinatoystorethatissellingPokemon.CustomerswhobuymorethanonetypeofPokemongeta
discount.ThesametypeofPokemoncannotbeaddedtoadiscountgroup.
NumberofDifferentPokemon
Purchased
DiscountAmount
Nodiscount
10%
20%
PokemonforSale
Price
Pikachu
$6
Squirtle
$5
Charmander
$5
Requirements
ThecompletedprogramshouldbeabletocalculatethebestpossiblediscountforanycollectionofPokemon.
Youmayusemultipletransactionstogetthebestprice.
EachexampleshouldbetranslatedintoaUnitTest.NoUIcomponentisrequired,eachtestscenariomaybe
hardcoded.AdditionalUnitTestsareencouraged.
Competitiveadvantage
Wewillbelookingtointerviewthoseindividualswhosecompletedexercisemostcloselyadherestothe
principleslistedinthebookCleanCode.Ifyouareunfamiliarwiththisbook,donotworry.Justtrytowrite
yourcodeinamannerwhichleavesyoufeelingproudoftheendproduct.
ExampleOne
Purchased1Pikachu
Shouldyield$6.00
ExampleTwo
Purchased2Pikachu
Shouldyield$12.00
ExampleThree
Purchased1Pikachu
Purchased1Squirtle
Shouldyield$9.90
ExampleFour* notethateachgroupoftwoPokemonreceivesa10%discount.
Purchased2Pikachu
Purchased2Squirtle
Shouldyield$19.80* 2xExample3=>$9.90+$9.90=$19.80
ExampleFive* notethateachgroupoftwoPokemonreceivesa10%discount.
Purchased3Pikachu
Purchased3Squirtle
Shouldyield$29.70* 3xExample3=>$9.90+$9.90+$9.90=$29.70
ExampleSix* notethatthe10%discountdoesnotapplytothesecondPikachu.
Purchased2Pikachu
PurchasedSquirtle
Shouldyield$15.90
ExampleSeven
Purchased1Pikachu
Purchased1Squirtle
Purchased1Charmander
Shouldyield$12.80
ExampleEight* notethatthe20%discountappliestothethreegroupedPokemon,butnottheadditional
ungroupedPikachu.
Purchased2Pikachu
Purchased1Squirtle
Purchased1Charmander
Shouldyield$18.80