Welcome to Nick and Ian's DevPro Christmas Code-Off 2024! We will review these instructions with you before starting the timer.
Every mistake in your solution will add 1 minute to your time! Also, if your solution fails to produce the exact output for part 1 will result in a 5 minute penalty.
npm installnpm start
- Create
NicenessRating.tsexporting aNicenessRatingenum with 4 values:NICEVERY_NICENAUGHTYVERY_NAUGHTY
- Convert hardcoded strings to enum references in
main.tsandCoalCalculator.ts. - Refactor all nicenessRating function arguments to use the new enum.
- Lines 7-15, refactor nicenessRating
if-else-ifto a switch statement. - Lines 17-23, remove
elsestatements and return totalCoal as soon as it is known. - Extract coalCoefficient and totalCoal calculations into separate methods named
getCoalCoefficientandgetTotalCoal.
- Rename the
GiftThingclass toGiftCalculator. - Rename the
GiftThing.tsfile toGiftCalculator.ts. - Remove
elsestatements ingetGiftThingand return giftTotal as soon as it is known. - Rename the
getGiftThingmethod togetGiftTotal.
- create a
Person.tsfile and create and export aPersoninterface containing the following fields:nameof typestringageof typenumbernicenessRatingof typeNicenessRating
- Update the
printGiftTotalmethod inmain.tsto take in a singlePersonargument instead of 3 seperate arguments.
- Create and export a new
NiceListclass in a newNiceList.tsfile with one method calledgetListreturning an array ofPerson. Return the hard-coded values insantasListfrommain.tsfrom this method. - Update
main.tsto use the new function to populatesantasList.
- Move
CoalCalculator.tsandGiftCalculator.tsinto a newcalculatordirectory undersrc. - Move
Person.tsandNicenessRating.tsinto a newmodeldirectory undersrc.
Nick recieves: 1 gifts
Nick Jr. recieves: 2 gifts
Baby Nick recieves: 3 gifts
Ian recieves: 1 gifts
Ian Jr. recieves: 2 gifts
Baby Ian recieves: 3 gifts
Rawley recieves: 4 lumps of coal
Rawley Jr. recieves: 1 lumps of coal
Baby Rawley recieves: 1 gifts
Tim recieves: 9 lumps of coal
Tim Jr. recieves: 4 lumps of coal
Baby Tim recieves: 1 lumps of coal
Manually convert the InvoiceListDto class in JavaClass.java into a valid JSON object with the same schema.
Include the the following values with the JSON object:
{
[
{
0d16892e-7992-4d70-9301-d7ecaca1ebd3
553ba3a1-24b4-433b-a0e2-4f210b71aaaa
"Jan-15-2023"
"Sep-1-2024"
"PAID"
"Nick&Ian"
"ACME Coding INC. Memo: Fixed all DevPro bugs"
"ACME Coding INC."
"[email protected]"
"P. Sherman, 42 Wallaby Way, Sydney"
"H. Potter, 42 Privet Drive, Little Whinging, England"
9001
"$800"
"$800,000"
[
{
6fb56f4a-9b36-4a04-b1f6-7960b8907be8
aa426d90-c699-4e1a-b871-f54ad0566e85
"Nick&Ian"
}
]
false
true
}
]
"oldInvoices"
}