-
Notifications
You must be signed in to change notification settings - Fork 0
/
CircularReferenceExampleSolution.sol
54 lines (45 loc) · 1.71 KB
/
CircularReferenceExampleSolution.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
49
50
51
52
53
54
pragma solidity ^0.4.17;
contract VotethPost {
string public title;
string public content;
address public author;
string public nickname;
address[] public votethComments;
address public votethCommentMaker;
constructor(string _title, string _content, string _nickname) public {
title = _title;
content = _content;
nickname = _nickname;
author = msg.sender;
votethCommentMaker = new VotethCommentMaker();
}
function addComment(string _comment, string _nickname) public {
address comment = new VotethComment(_comment, _nickname, msg.sender, votethCommentMaker);
votethComments.push(comment);
}
}
contract VotethComment {
string public comment;
string public nickname;
address public author;
address[] public votethComments;
address votethCommentMaker;
constructor(string _comment, string _nickname, address _author, address _votethCommentMaker) public {
comment = _comment;
nickname = _nickname;
author = _author;
votethCommentMaker = _votethCommentMaker;
}
function addComment(string _comment, string _nickname) public {
VotethCommentSupplier votethCommentSupplier = VotethCommentSupplier(votethCommentMaker);
votethComments.push(votethCommentSupplier.makeComment(_comment, _nickname, msg.sender));
}
}
contract VotethCommentSupplier {
function makeComment(string _comment, string _nickname, address _author) public returns(address);
}
contract VotethCommentMaker {
function makeComment(string _comment, string _nickname, address _author) public returns(address) {
return new VotethComment(_comment, _nickname, _author, this);
}
}