Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write an uml diagramm package decorator trait Pizza: def diameter: Int def price: BigDecimal class Margherita extends Pizza: override def diameter: Int = 2 8
Write an uml diagramm
package decorator
trait Pizza:
def diameter: Int
def price: BigDecimal
class Margherita extends Pizza:
override def diameter: Int
override def price: BigDecimal
class Funghi extends Margherita:
override def price: BigDecimal
class Verdura extends Margherita:
override def price: BigDecimal
@main def Pizzashop: Unit
pizza Verdura with extra cheese
val p: Pizza new ExtraCheesenew Verdura
pizza Funghi family size with vegan cheese
val p: Pizza new VeganCheesenew FamilyPizzanew Funghi
printlnsPrice of a pizza verdura with extra cheese is $pprice
printlnsPrice of a pizza funghi family size with vegan cheese is $pprice
trait PizzaDecorator extends Pizza
protected val pizza: Pizza
class ExtraCheeseval pizza: Pizza extends PizzaDecorator
override def diameter: Int pizza.diameter
override def price: BigDecimal pizza.price
class VeganCheeseval pizza: Pizza extends PizzaDecorator
override def diameter: Int pizza.diameter
override def price: BigDecimal pizza.price
class ExtraOnionsval pizza: Pizza extends PizzaDecorator
override def diameter: Int pizza.diameter
override def price: BigDecimal pizza.price
class FamilyPizzaval pizza: Pizza extends PizzaDecorator
override def diameter: Int
override def price: BigDecimal pizza.price
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started