Inheritance & Visibility

Do you have an actual contract in remix saved as DogContract1.sol? That is required in order to import it.

Hi Filip enclosed are two screenshots showing unable to import. I am using firefox trying few different URL,s . Same result with Google Chrome also. Local host connected. Thank you.

Your contract file needs to be names DogContract.sol. Right now the name is importto.sol. That’s why it doesn’t work.

Hi Filip. Yes it works… Thanks::+1:

1 Like

I would like to know how to perform inheritance in super block studio. Thanks.

2 Likes

As of now, superblocks doesn’t support multiple solidity files. You would have to create multiple contracts within the same solidity file. I will also check with my contact over at superblocks to see if that’s a feature that they are working on.

1 Like

Man, the herd has thinned!

1 Like

Accidentally posted this assignment on 5066 instead of 5065

pragma solidity ^0.4.0;

contract PersonContract{

struct Person {
    string name;
    uint age;
}

Person[] People;

    // setter function 
function addPerson(string _cname, uint _age) {
   People.push(Person(_cname, _age));
}

// getter function that returns Average Age over all the persons in the array People
function getAverageAge() returns (uint){
    
    uint numOfPersons = 0;
    uint totalAge = 0;
    
    for(uint i = 0; i < People.length; i++ ) {
        totalAge += People[i].age;
        numOfPersons++;
    }
    
    return totalAge/numOfPersons;
}

}

1 Like

Hello everyone. Can I get some help, please? I am getting these undeclared identifiers errors. Where did I make the mistake?

Thank you.

It should be

address owner = msg.sender;

not

address.owner = msg.sender;

I hope that helps.

1 Like

OMG yes, that was it… amazing how a single dot can make one go nuts lol … thanks a lot, Filip!

1 Like

Hi Filip, thanks for your great help.
This is a general question about Solidity: Is there a practical way in Solidity to retrieve / get more than one element at a time? If not? What would be an efficient way to achieve it?