Exercise - Demonstrate your knowledge of structs.
GarageManager
. Add the following in storage:
garage
to store a list of Car
s (described below), indexed by addressstruct
called Car
. It should store the following properties:
make
model
color
numberOfDoors
addCar
that adds a car to the user’s collection in the garage
. It should:
msg.sender
to determine the ownerCar
Car
to the garage
under the user’s addressgetMyCars
. It should return an array with all of the cars owned by the calling user.
getUserCars
. It should return an array with all of the cars for any given address
.
updateCar
. It should accept a uint
for the index of the car to be updated, and arguments for all of the Car
types.
If the sender doesn’t have a car at that index, it should revert with a custom error
BadCarIndex
and the index provided.
Otherwise, it should update that entry to the new properties.
resetMyGarage
. It should delete the entry in garage
for the sender.
⚠️ Spoiler Alert: Open only if tests fail