I want one object of that struct car and I am not sure how it could be done any other way.
Like if I want to register two cars, then this is one way of doing it. Do you have any other way?
Sep 30, 2019, 8:08 PM
I'm also new to solidity
But i think you can get any car you mapped with a get function
Call up something like
Car[totalCars]
Since the counter increments by one before any addition
Call up something like
Car[totalCars]
Since the counter increments by one before any addition
Like
Function GetCarReg (uint memory _totalCars) public returns {
return (Car[_totalCars]);
}
Function GetCarReg (uint memory _totalCars) public returns {
return (Car[_totalCars]);
}
Don't laugh at me.. Just thinking it should work 😂
Sep 30, 2019, 8:18 PM
For that to work, i need to create an object which gets stored in car[x] so first am creating and storing an object there
Its not required at all. Solidity creates a getter function itself if the variable is declared as public
Sep 30, 2019, 8:18 PM
Exactly.. That's why i used the one there already.. Ie totalCars that increments by one on every addition
Yeah that's true..
CarSeriaNumber will get it..
Didn't notice you made it public though
Sep 30, 2019, 8:20 PM
Well, am getting stuck at the initial step. Am not able to call registerCar method. Its giving error when running on testnet
But running fine on remix jvm
Sep 30, 2019, 8:20 PM
Can you try it the way i just told you to test?
Don't worry
Sep 30, 2019, 8:22 PM
I didn't fully understand that. Can you provide me a registerCar method?
I guess you provided getCarReg method
I guess you provided getCarReg method
But I need the method to register a car
Sep 30, 2019, 8:23 PM
Leave the get car method cos you can do that through CarSeriaNumber
Sep 30, 2019, 8:24 PM