SlideShare uma empresa Scribd logo
1 de 28
Baixar para ler offline
with Scala
Let’s plan a party
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
github.com/DanyMariaLee/
partyplanner
The task
Parse data Calculate Print result
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
use worksheet
or
REPL
google it
Try again
Data models
case class Price(product: String,
value: Double)
Price("cola", 1.5)
case class Consumption(product: String,
value: Double)
Consumption("cake", 0.01)
case class Party(name: String,
products: List[String])
Party("birthday", List("cake", "balloon"))
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
Request
case class Request(party: Party,
numberOfPeople: Int,
budget: Double)
Request(
Party("birthday", List("cake",
"balloon")),
10, 100.5)
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
Receipt
case class Receipt(request: Request,
totalAmount: Double)
Receipt(
Request(
Party("Party name", List("product")),
3, 100.0), 6.0)
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
Parse data
package partyplanner.utils
/**
* @return List[String] containing lines from file with `name`
* For example for file name.txt
*
* product1;value1
* product2;value2
* product3;value3
*
* result will be
*
* List("product1;value1", "product2;value2", "product3;value3")
*
* @param name Is the name of a file you want to read (e.g. "price.txt")
*/
def loadDataFromFile(name: String): List[String] = {
val stream: InputStream = getClass.getResourceAsStream(name)
scala.io.Source.fromInputStream(stream).getLines.toList
}
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
Parse data
import utils.Utils.loadDataFromFile
All data is in resources folder: party.txt, price.txt, consumption.txt
Use `split` function
val arr = "boo:and:foo".split(":") // results to Array("boo", "and", "foo")
Access each element by index
arr(0) // results to "boo"
Don't forget to transform String into Double type when necessary
"2".toDouble // 2: Double
"a".toDouble // throws an Exception
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
price.txt
/**
* @return List[Price] containing prices from file in resource
* For example for line
*
* "apple;1.5"
*
* price should be Price("apple", 1.5)
*/
def parsePrices: List[Price] = ???
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
price.txt
banana;2
coffee;1
Price("banana", 2)
Price("coffee", 1)
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
consumption.txt
/**
* @return List[Consumption] containing
* consumptions from file in resource
* For example for line
*
* "apple;0.5"
*
* consumption should be Consumption("apple", 0.5)
*/
def parseConsumptions: List[Consumption] = ???
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
consumption.txt
banana;0.2
coffee;0.5
Consumption("banana", 0.2)
Consumption("coffee", 0.5)
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
party.txt
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
/**
* @return List[Party] containing Party from file in resource
* For example for lines
*
* "birthday;coffee"
* "birthday;cola"
*
* party should be Party("birthday", List("coffee", "cola"))
*/
def parseParties: List[Party] = ???
party.txt
birthday;banana
birthday;coffee
corporate;vine
corporate;fish
Party(“birthday", List(“coffee”, "coffee"))
Party(“corporate", List(“vine”, “fish"))
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
Run test
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
Calculation
ONE product
for
ONE person
ALL products
for
ONE person
Total amount
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
ONE product
for
ONE person
consumption * price = product amount
Price("coffee", 1)Consumption("banana", 0.2)
C * P = A (product, person)
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
ALL products
for
ONE person
A1 + A2 + A3 + … + An = A(person)
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
Total amount
A(person) * number of people = total amount
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
Console dialog
party type
number of people
budget
Request
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
Console dialog
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
To get data from console we have
scala.io.StdIn object with methods for each type.
For example to get an Int
scala.io.StdIn.readInt()
! This method throws an exception if
user types a wrong type.
Console dialog
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
Hey there, it's a party planner app!
We are offering different types of parties:
0 - birthday
1 - cocktail
2 - garden
3 - corporate
Please, pick the type of your party
Please, pick the type of your party
0
How many people will be at the party?
10
What is your budget for this party?
1000
Receipt
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
--------------------
Birthday party for 10 people
cake
balloon
cola
icecream
banana
TOTAL $37.0
--------------------
THANK YOU!
10 February 2018
Contact me
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence
twitter @besseifunction
Thank you!
© 2018 The Quantium Group Pty Ltd. In Commercial Confidence

Mais conteúdo relacionado

Semelhante a Party planner workshop

Effective Cost Optimization for Business (ARC201) - AWS re:Invent 2018
Effective Cost Optimization for Business (ARC201) - AWS re:Invent 2018Effective Cost Optimization for Business (ARC201) - AWS re:Invent 2018
Effective Cost Optimization for Business (ARC201) - AWS re:Invent 2018Amazon Web Services
 
From Startup to Recognized IoT Leader
From Startup to Recognized IoT Leader From Startup to Recognized IoT Leader
From Startup to Recognized IoT Leader Amazon Web Services
 
Remediate Tech Debt or Drive Innovation - AWS Summit Sydney 2018
Remediate Tech Debt or Drive Innovation - AWS Summit Sydney 2018Remediate Tech Debt or Drive Innovation - AWS Summit Sydney 2018
Remediate Tech Debt or Drive Innovation - AWS Summit Sydney 2018Amazon Web Services
 
Zendesk: Building a World-Class Cloud Center of Excellence (ENT309-S) - AWS r...
Zendesk: Building a World-Class Cloud Center of Excellence (ENT309-S) - AWS r...Zendesk: Building a World-Class Cloud Center of Excellence (ENT309-S) - AWS r...
Zendesk: Building a World-Class Cloud Center of Excellence (ENT309-S) - AWS r...Amazon Web Services
 
Anatomy of a Successful IoT Project, ft. Pentair (IOT202) - AWS re:Invent 2018
Anatomy of a Successful IoT Project, ft. Pentair (IOT202) - AWS re:Invent 2018Anatomy of a Successful IoT Project, ft. Pentair (IOT202) - AWS re:Invent 2018
Anatomy of a Successful IoT Project, ft. Pentair (IOT202) - AWS re:Invent 2018Amazon Web Services
 
AWS 인공지능 서비스와 서버리스 서비스를 이용한 동영상 분석 서비스 구축하기 (김현수/황윤상, AWS 솔루션즈 아키텍트) :: AWS D...
AWS 인공지능 서비스와 서버리스 서비스를 이용한 동영상 분석 서비스 구축하기 (김현수/황윤상, AWS 솔루션즈 아키텍트) :: AWS D...AWS 인공지능 서비스와 서버리스 서비스를 이용한 동영상 분석 서비스 구축하기 (김현수/황윤상, AWS 솔루션즈 아키텍트) :: AWS D...
AWS 인공지능 서비스와 서버리스 서비스를 이용한 동영상 분석 서비스 구축하기 (김현수/황윤상, AWS 솔루션즈 아키텍트) :: AWS D...Amazon Web Services Korea
 
Smith & Jones 2019 Trends Stat Pack
Smith & Jones 2019 Trends Stat Pack Smith & Jones 2019 Trends Stat Pack
Smith & Jones 2019 Trends Stat Pack Smith & Jones
 
Kotlin과 AWS와 함께라면 육군훈련소도 외롭지 않아::강성훈::AWS Summit Seoul 2018
Kotlin과 AWS와 함께라면 육군훈련소도 외롭지 않아::강성훈::AWS Summit Seoul 2018Kotlin과 AWS와 함께라면 육군훈련소도 외롭지 않아::강성훈::AWS Summit Seoul 2018
Kotlin과 AWS와 함께라면 육군훈련소도 외롭지 않아::강성훈::AWS Summit Seoul 2018Amazon Web Services Korea
 
Kotlin, AWS와 함께라면 육군훈련소도 외롭지 않아
Kotlin, AWS와 함께라면 육군훈련소도 외롭지 않아Kotlin, AWS와 함께라면 육군훈련소도 외롭지 않아
Kotlin, AWS와 함께라면 육군훈련소도 외롭지 않아Sunghoon Kang
 
Better Business From Exploring Ideas - AWS Summit Sydney 2018
Better Business From Exploring Ideas - AWS Summit Sydney 2018Better Business From Exploring Ideas - AWS Summit Sydney 2018
Better Business From Exploring Ideas - AWS Summit Sydney 2018Amazon Web Services
 
DSLs and Language Design in Machine Learning
DSLs and Language Design in Machine LearningDSLs and Language Design in Machine Learning
DSLs and Language Design in Machine LearningMattia Ferrini
 
Amali Solutions Group Overview
Amali Solutions Group OverviewAmali Solutions Group Overview
Amali Solutions Group OverviewKevin May
 
The Future of Enterprise IT - Lessons Learned
The Future of Enterprise IT - Lessons LearnedThe Future of Enterprise IT - Lessons Learned
The Future of Enterprise IT - Lessons LearnedAmazon Web Services
 
QCon 2018 | Gimel | PayPal's Analytic Platform
QCon 2018 | Gimel | PayPal's Analytic PlatformQCon 2018 | Gimel | PayPal's Analytic Platform
QCon 2018 | Gimel | PayPal's Analytic PlatformDeepak Chandramouli
 
Maximize Innovation and Agility by Building Your SaaS Solution on AWS (GPSBUS...
Maximize Innovation and Agility by Building Your SaaS Solution on AWS (GPSBUS...Maximize Innovation and Agility by Building Your SaaS Solution on AWS (GPSBUS...
Maximize Innovation and Agility by Building Your SaaS Solution on AWS (GPSBUS...Amazon Web Services
 
데이터 라벨링 노가다는 이제 그만 - Amazon Sagemaker Ground Truth :: 소성운 -...
데이터 라벨링 노가다는 이제 그만 - Amazon Sagemaker Ground Truth :: 소성운 -...데이터 라벨링 노가다는 이제 그만 - Amazon Sagemaker Ground Truth :: 소성운 -...
데이터 라벨링 노가다는 이제 그만 - Amazon Sagemaker Ground Truth :: 소성운 -...AWSKRUG - AWS한국사용자모임
 
re:Invent 2018 Recap Digital Advertising (Japanese)
re:Invent 2018 Recap Digital Advertising (Japanese)re:Invent 2018 Recap Digital Advertising (Japanese)
re:Invent 2018 Recap Digital Advertising (Japanese)Amazon Web Services Japan
 
AWS Startup Day Toronto - Sudip Chakrabarti- Building & Selling AI-Powered En...
AWS Startup Day Toronto - Sudip Chakrabarti- Building & Selling AI-Powered En...AWS Startup Day Toronto - Sudip Chakrabarti- Building & Selling AI-Powered En...
AWS Startup Day Toronto - Sudip Chakrabarti- Building & Selling AI-Powered En...Amazon Web Services
 

Semelhante a Party planner workshop (20)

Effective Cost Optimization for Business (ARC201) - AWS re:Invent 2018
Effective Cost Optimization for Business (ARC201) - AWS re:Invent 2018Effective Cost Optimization for Business (ARC201) - AWS re:Invent 2018
Effective Cost Optimization for Business (ARC201) - AWS re:Invent 2018
 
From Startup to Recognized IoT Leader
From Startup to Recognized IoT Leader From Startup to Recognized IoT Leader
From Startup to Recognized IoT Leader
 
Remediate Tech Debt or Drive Innovation - AWS Summit Sydney 2018
Remediate Tech Debt or Drive Innovation - AWS Summit Sydney 2018Remediate Tech Debt or Drive Innovation - AWS Summit Sydney 2018
Remediate Tech Debt or Drive Innovation - AWS Summit Sydney 2018
 
Keynote
KeynoteKeynote
Keynote
 
Zendesk: Building a World-Class Cloud Center of Excellence (ENT309-S) - AWS r...
Zendesk: Building a World-Class Cloud Center of Excellence (ENT309-S) - AWS r...Zendesk: Building a World-Class Cloud Center of Excellence (ENT309-S) - AWS r...
Zendesk: Building a World-Class Cloud Center of Excellence (ENT309-S) - AWS r...
 
Anatomy of a Successful IoT Project, ft. Pentair (IOT202) - AWS re:Invent 2018
Anatomy of a Successful IoT Project, ft. Pentair (IOT202) - AWS re:Invent 2018Anatomy of a Successful IoT Project, ft. Pentair (IOT202) - AWS re:Invent 2018
Anatomy of a Successful IoT Project, ft. Pentair (IOT202) - AWS re:Invent 2018
 
Industrial Transformation
Industrial TransformationIndustrial Transformation
Industrial Transformation
 
AWS 인공지능 서비스와 서버리스 서비스를 이용한 동영상 분석 서비스 구축하기 (김현수/황윤상, AWS 솔루션즈 아키텍트) :: AWS D...
AWS 인공지능 서비스와 서버리스 서비스를 이용한 동영상 분석 서비스 구축하기 (김현수/황윤상, AWS 솔루션즈 아키텍트) :: AWS D...AWS 인공지능 서비스와 서버리스 서비스를 이용한 동영상 분석 서비스 구축하기 (김현수/황윤상, AWS 솔루션즈 아키텍트) :: AWS D...
AWS 인공지능 서비스와 서버리스 서비스를 이용한 동영상 분석 서비스 구축하기 (김현수/황윤상, AWS 솔루션즈 아키텍트) :: AWS D...
 
Smith & Jones 2019 Trends Stat Pack
Smith & Jones 2019 Trends Stat Pack Smith & Jones 2019 Trends Stat Pack
Smith & Jones 2019 Trends Stat Pack
 
Kotlin과 AWS와 함께라면 육군훈련소도 외롭지 않아::강성훈::AWS Summit Seoul 2018
Kotlin과 AWS와 함께라면 육군훈련소도 외롭지 않아::강성훈::AWS Summit Seoul 2018Kotlin과 AWS와 함께라면 육군훈련소도 외롭지 않아::강성훈::AWS Summit Seoul 2018
Kotlin과 AWS와 함께라면 육군훈련소도 외롭지 않아::강성훈::AWS Summit Seoul 2018
 
Kotlin, AWS와 함께라면 육군훈련소도 외롭지 않아
Kotlin, AWS와 함께라면 육군훈련소도 외롭지 않아Kotlin, AWS와 함께라면 육군훈련소도 외롭지 않아
Kotlin, AWS와 함께라면 육군훈련소도 외롭지 않아
 
Better Business From Exploring Ideas - AWS Summit Sydney 2018
Better Business From Exploring Ideas - AWS Summit Sydney 2018Better Business From Exploring Ideas - AWS Summit Sydney 2018
Better Business From Exploring Ideas - AWS Summit Sydney 2018
 
DSLs and Language Design in Machine Learning
DSLs and Language Design in Machine LearningDSLs and Language Design in Machine Learning
DSLs and Language Design in Machine Learning
 
Amali Solutions Group Overview
Amali Solutions Group OverviewAmali Solutions Group Overview
Amali Solutions Group Overview
 
The Future of Enterprise IT - Lessons Learned
The Future of Enterprise IT - Lessons LearnedThe Future of Enterprise IT - Lessons Learned
The Future of Enterprise IT - Lessons Learned
 
QCon 2018 | Gimel | PayPal's Analytic Platform
QCon 2018 | Gimel | PayPal's Analytic PlatformQCon 2018 | Gimel | PayPal's Analytic Platform
QCon 2018 | Gimel | PayPal's Analytic Platform
 
Maximize Innovation and Agility by Building Your SaaS Solution on AWS (GPSBUS...
Maximize Innovation and Agility by Building Your SaaS Solution on AWS (GPSBUS...Maximize Innovation and Agility by Building Your SaaS Solution on AWS (GPSBUS...
Maximize Innovation and Agility by Building Your SaaS Solution on AWS (GPSBUS...
 
데이터 라벨링 노가다는 이제 그만 - Amazon Sagemaker Ground Truth :: 소성운 -...
데이터 라벨링 노가다는 이제 그만 - Amazon Sagemaker Ground Truth :: 소성운 -...데이터 라벨링 노가다는 이제 그만 - Amazon Sagemaker Ground Truth :: 소성운 -...
데이터 라벨링 노가다는 이제 그만 - Amazon Sagemaker Ground Truth :: 소성운 -...
 
re:Invent 2018 Recap Digital Advertising (Japanese)
re:Invent 2018 Recap Digital Advertising (Japanese)re:Invent 2018 Recap Digital Advertising (Japanese)
re:Invent 2018 Recap Digital Advertising (Japanese)
 
AWS Startup Day Toronto - Sudip Chakrabarti- Building & Selling AI-Powered En...
AWS Startup Day Toronto - Sudip Chakrabarti- Building & Selling AI-Powered En...AWS Startup Day Toronto - Sudip Chakrabarti- Building & Selling AI-Powered En...
AWS Startup Day Toronto - Sudip Chakrabarti- Building & Selling AI-Powered En...
 

Último

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 

Último (20)

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 

Party planner workshop

  • 1. with Scala Let’s plan a party © 2018 The Quantium Group Pty Ltd. In Commercial Confidence
  • 3. The task Parse data Calculate Print result © 2018 The Quantium Group Pty Ltd. In Commercial Confidence
  • 7. Data models case class Price(product: String, value: Double) Price("cola", 1.5) case class Consumption(product: String, value: Double) Consumption("cake", 0.01) case class Party(name: String, products: List[String]) Party("birthday", List("cake", "balloon")) © 2018 The Quantium Group Pty Ltd. In Commercial Confidence
  • 8. Request case class Request(party: Party, numberOfPeople: Int, budget: Double) Request( Party("birthday", List("cake", "balloon")), 10, 100.5) © 2018 The Quantium Group Pty Ltd. In Commercial Confidence
  • 9. Receipt case class Receipt(request: Request, totalAmount: Double) Receipt( Request( Party("Party name", List("product")), 3, 100.0), 6.0) © 2018 The Quantium Group Pty Ltd. In Commercial Confidence
  • 10. Parse data package partyplanner.utils /** * @return List[String] containing lines from file with `name` * For example for file name.txt * * product1;value1 * product2;value2 * product3;value3 * * result will be * * List("product1;value1", "product2;value2", "product3;value3") * * @param name Is the name of a file you want to read (e.g. "price.txt") */ def loadDataFromFile(name: String): List[String] = { val stream: InputStream = getClass.getResourceAsStream(name) scala.io.Source.fromInputStream(stream).getLines.toList } © 2018 The Quantium Group Pty Ltd. In Commercial Confidence
  • 11. Parse data import utils.Utils.loadDataFromFile All data is in resources folder: party.txt, price.txt, consumption.txt Use `split` function val arr = "boo:and:foo".split(":") // results to Array("boo", "and", "foo") Access each element by index arr(0) // results to "boo" Don't forget to transform String into Double type when necessary "2".toDouble // 2: Double "a".toDouble // throws an Exception © 2018 The Quantium Group Pty Ltd. In Commercial Confidence
  • 12. price.txt /** * @return List[Price] containing prices from file in resource * For example for line * * "apple;1.5" * * price should be Price("apple", 1.5) */ def parsePrices: List[Price] = ??? © 2018 The Quantium Group Pty Ltd. In Commercial Confidence
  • 13. price.txt banana;2 coffee;1 Price("banana", 2) Price("coffee", 1) © 2018 The Quantium Group Pty Ltd. In Commercial Confidence
  • 14. consumption.txt /** * @return List[Consumption] containing * consumptions from file in resource * For example for line * * "apple;0.5" * * consumption should be Consumption("apple", 0.5) */ def parseConsumptions: List[Consumption] = ??? © 2018 The Quantium Group Pty Ltd. In Commercial Confidence
  • 16. party.txt © 2018 The Quantium Group Pty Ltd. In Commercial Confidence /** * @return List[Party] containing Party from file in resource * For example for lines * * "birthday;coffee" * "birthday;cola" * * party should be Party("birthday", List("coffee", "cola")) */ def parseParties: List[Party] = ???
  • 18. Run test © 2018 The Quantium Group Pty Ltd. In Commercial Confidence
  • 19. Calculation ONE product for ONE person ALL products for ONE person Total amount © 2018 The Quantium Group Pty Ltd. In Commercial Confidence
  • 20. ONE product for ONE person consumption * price = product amount Price("coffee", 1)Consumption("banana", 0.2) C * P = A (product, person) © 2018 The Quantium Group Pty Ltd. In Commercial Confidence
  • 21. ALL products for ONE person A1 + A2 + A3 + … + An = A(person) © 2018 The Quantium Group Pty Ltd. In Commercial Confidence
  • 22. Total amount A(person) * number of people = total amount © 2018 The Quantium Group Pty Ltd. In Commercial Confidence
  • 23. Console dialog party type number of people budget Request © 2018 The Quantium Group Pty Ltd. In Commercial Confidence
  • 24. Console dialog © 2018 The Quantium Group Pty Ltd. In Commercial Confidence To get data from console we have scala.io.StdIn object with methods for each type. For example to get an Int scala.io.StdIn.readInt() ! This method throws an exception if user types a wrong type.
  • 25. Console dialog © 2018 The Quantium Group Pty Ltd. In Commercial Confidence Hey there, it's a party planner app! We are offering different types of parties: 0 - birthday 1 - cocktail 2 - garden 3 - corporate Please, pick the type of your party Please, pick the type of your party 0 How many people will be at the party? 10 What is your budget for this party? 1000
  • 26. Receipt © 2018 The Quantium Group Pty Ltd. In Commercial Confidence -------------------- Birthday party for 10 people cake balloon cola icecream banana TOTAL $37.0 -------------------- THANK YOU! 10 February 2018
  • 27. Contact me © 2018 The Quantium Group Pty Ltd. In Commercial Confidence twitter @besseifunction
  • 28. Thank you! © 2018 The Quantium Group Pty Ltd. In Commercial Confidence