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 classin Kotlin automatically getsequals,hashCode,toStringandcopy— exactly what you want for holding data. - The fields mirror what the server returns:
id,name,description,price(in euros, aDouble),category,imageUrl(can benull, henceString?).
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.
pricehere is aDouble(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 aDoubleis enough.