-
Notifications
You must be signed in to change notification settings - Fork 0
/
School.sol
executable file
·48 lines (36 loc) · 1.18 KB
/
School.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
pragma solidity ^0.4.15;
import "./Student.sol";
contract School{
address registryID;
address schoolOwner;
bytes32 schoolName;
address[] studentContracts;
function School(bytes32 _name) public{
registryID = msg.sender;
schoolName = _name;
}
function setSchoolOwner(address _schoolAdd) public{
if (msg.sender != registryID) { revert(); }
schoolOwner = _schoolAdd;
}
modifier onlySchoolOwner{
if (msg.sender != schoolOwner){
revert();
}
_;
}
function getName() public constant returns(bytes32){
return schoolName;
}
function newStudent(bytes32 _fName, bytes32 _lName, bytes32 _mailingAdd, bytes32 _transcript) onlySchoolOwner public{
address studentAddress = new Student( _fName, _lName, _mailingAdd, _transcript);
if (studentAddress == 0x0) {revert();}
studentContracts.push(studentAddress);
}
function transferStudent(address _studentContract) onlySchoolOwner public{
studentContracts.push(_studentContract);
}
function getBalance() onlySchoolOwner constant public returns(uint){
return this.balance;
}
}