I am a beginner user of solidity so I have to learn a lot. I am creating a car sales Dapp for a school assignment in remix and I can't figure out how I can keep updating an array value using user inputs. I want the possibility to update the mileage of a car wich has to be greater than the previous value using user inputs and it has to be connected to the licenseplate of a car.
At the "//" code on the bottom I get these 2 errors: TypeError: Type address is not implicitly convertible to expected type uint256. (pointing to "[msg.sender]".
TypeError: Indexed expression has to be a type, mapping or array (is struct CarApp.Car storage ref) (pointing to "cars[msg.sender]
pragma solidity >=0.8.2 <0.9.0;
contract CarApp {
address public owner;
struct Car {
string licensePlate;
string chassisNumber;
string brand;
string carType;
string colour;
uint256 mileage;
address owner;
}
constructor() {
owner = msg.sender;
}
Car[] public cars;
function createCar(string memory _licensePlate, string memory _chassisNumber, string memory _brand, string memory _carType, string memory _colour) public {
require(bytes(_licensePlate).length > 0, "Please fill in your license plate");
require(bytes(_chassisNumber).length > 0, "Please fill in your chassis number");
require(bytes(_brand).length > 0, "Please fill in the brand of the car");
require(bytes(_carType).length > 0, "Please fill in the car type");
require(bytes(_colour).length > 0, "Please fill in the colour of the car");
cars.push (Car(_licensePlate, _chassisNumber, _brand, _carType, _colour, 0, owner));
}
function getCarInfo() external view returns(Car[] memory) {
return cars;
}
//function addMileage(string memory _licensePlate, uint256 _mileage) public {
//require(bytes (_licensePlate).length > 0, "Please fill in your license plate");
//require(_mileage > cars[msg.sender][_licensePlate].mileage, "The mileage should be higher than the previous one");
//cars[msg.sender][_licensePlate].mileage = _mileage;
//}
}