// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;
interface ISubmission {
function getApprovedRecords() external view returns (string[] memory);
function addRecord(string memory _albumName) external;
function getUserFavorites(
address _address
) external view returns (string[] memory);
function resetUserFavorites() external;
}
contract Submission is ISubmission {
mapping(address => string[]) public userFavorites;
function getApprovedRecords()
external
pure
override
returns (string[] memory)
{
string[] memory approved = new string[](9);
approved[0] = "Thriller";
approved[1] = "Back in Black";
approved[2] = "The Bodyguard";
approved[3] = "The Dark Side of the Moon";
approved[4] = "Their Greatest Hits (1971-1975)";
approved[5] = "Hotel California";
approved[6] = "Come On Over";
approved[7] = "Rumours";
approved[8] = "Saturday Night Fever";
return approved;
}
function addRecord(string memory _albumName) external override {
userFavorites[msg.sender].push(_albumName);
}
function getUserFavorites(
address _address
) external view override returns (string[] memory) {
return userFavorites[_address];
}
function resetUserFavorites() external override {
delete userFavorites[msg.sender];
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;
interface IEmployee {
function idNumber() external returns (uint);
function managerId() external returns (uint);
}
interface ISalaried is IEmployee {
function annualSalary() external returns (uint);
}
interface IHourly is IEmployee {
function hourlyRate() external returns (uint);
}
interface ISalesPerson is IHourly {}
interface IEngineeringManager is ISalaried {}
interface IInheritanceSubmission {
function salesPerson() external returns (address);
function engineeringManager() external returns (address);
}
contract SalesPerson is ISalesPerson {
function hourlyRate() external pure override returns (uint) {
return 20;
}
function idNumber() external pure override returns (uint) {
return 55555;
}
function managerId() external pure override returns (uint) {
return 0;
}
}
contract EngineeringManager is IEngineeringManager {
function annualSalary() external pure override returns (uint) {
return 200_000;
}
function managerId() external pure override returns (uint) {
return 11111;
}
function idNumber() external pure override returns (uint) {
return 0;
}
}
contract InheritanceSubmission is IInheritanceSubmission {
SalesPerson private _salesPerson;
EngineeringManager private _engineeringManager;
constructor() {
_salesPerson = new SalesPerson();
_engineeringManager = new EngineeringManager();
}
function salesPerson() external view override returns (address) {
return address(_salesPerson);
}
function engineeringManager() external view override returns (address) {
return address(_engineeringManager);
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;
interface ISubmission {
struct Car {
string make;
string model;
string color;
uint numberOfDoors;
}
function addCar(
string calldata _make,
string calldata _model,
string calldata _color,
uint _numberOfDoors
) external;
function updateCar(
uint _index,
string calldata _make,
string calldata _model,
string calldata _color,
uint _numberOfDoors
) external;
function getUserCars(address _user) external view returns (Car[] memory);
function getMyCars() external view returns (Car[] memory);
function resetMyGarage() external;
}
contract Submission is ISubmission {
mapping(address => Car[]) private garages;
function addCar(
string calldata _make,
string calldata _model,
string calldata _color,
uint _numberOfDoors
) external override {
Car memory newCar = Car({
make: _make,
model: _model,
color: _color,
numberOfDoors: _numberOfDoors
});
garages[msg.sender].push(newCar);
}
function updateCar(
uint _index,
string calldata _make,
string calldata _model,
string calldata _color,
uint _numberOfDoors
) external override {
Car storage carToUpdate = garages[msg.sender][_index];
carToUpdate.make = _make;
carToUpdate.model = _model;
carToUpdate.color = _color;
carToUpdate.numberOfDoors = _numberOfDoors;
}
function getUserCars(
address _user
) external view override returns (Car[] memory) {
return garages[_user];
}
function getMyCars() external view override returns (Car[] memory) {
return garages[msg.sender];
}
function resetMyGarage() external override {
delete garages[msg.sender];
}
}Share Dialog
Support dialog
All comments (4)
I' having one error with Mappings Pin. I have pasted your code, however whenever I want to deploy the contract, I receive this error: "This contract may be abstract, it may not implement an abstract parent's methods completely or it may not invoke an inherited contract's constructor correctly.". Can you please assist? I tried with different compilers, tried to clear cash and cookies, nothing helped. Thanks
While in the Deploy tab, "Submission" should be selected in the Contract section, not "|Submission".
awesome mate. Thanks once again. it worked for me fine. Appreciate your support 👍
hi mate, appreciate your effort indeed.