Code

Create MenuItem.kt — the pizza model

Every piece of data in the app has a type. A pizza is a data class MenuItem. Create the package feature/menu/data and MenuItem.kt inside it.

  • A data class in Kotlin automatically gets equals, hashCode, toString and copy — exactly what you want for holding data.
  • The fields mirror what the server returns: id, name, description, price (in euros, a Double), category, imageUrl (can be null, hence String?).

Notice the package structure: feature/menu/data. All course, the app is split by feature (menu, cart, auth, orders, scan), and each feature into data (models, repositories) and presentation (UI, ViewModel). This is the real Pica structure.

Verify. After creating the file, the project should compile with no errors (Build → Make Project, or simply no red underlines in MenuItem.kt). MenuItem isn't used anywhere yet — that's fine; we use it in the next step.

Tip. price here is a Double (euros, e.g. 8.50). When the menu arrives from the server in lesson 5, the JSON sends cents (price_cents), and we convert those to euros. For now a Double is enough.