SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Ähnlich wie 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
 

Ähnlich wie 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...
 

Kürzlich hochgeladen

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
 
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
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
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
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
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
 
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
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
(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
 
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
 

Kürzlich hochgeladen (20)

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
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
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
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
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
 
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...
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
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
 
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
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
(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...
 
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...
 

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