Search⌘ K
AI Features

Exercise: Simulating a Pizza Factory

Explore how to define companion objects and factory functions in Kotlin through a hands-on exercise simulating a pizza factory. Understand how to create specific pizza variants like Hawaiian and Margherita using Kotlin's object-oriented features, enhancing your skills in practical class design and object creation.

We'll cover the following...

Problem statement

Define a companion object in the Pizza class that will contain factory functions for creating pizzas. The functions should be named hawaiian and margherita and should return pizzas with the following toppings:

  • ...