Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

24
LINES

< > BotCompany Repo | #1002518 // Java text game / QuestionNode

Java source code

1  
//QuestionNodes have a String data field as well as a reference to two other QuestionNodes.
2  
public class QuestionNode{
3  
4  
   public String data;
5  
   public QuestionNode yes;
6  
   public QuestionNode no;
7  
   
8  
   //Constructs a new QuestionNode with no references so it is a leaf node.
9  
   public QuestionNode(String data){
10  
      this(data, null, null);
11  
   }
12  
   
13  
   //Constructs a QuestionNode with references to the two specifified QuestionNodes.
14  
   public QuestionNode(String data, QuestionNode yes, QuestionNode no){
15  
      this.data = data;
16  
      this.yes = yes;
17  
      this.no = no;
18  
   }
19  
   
20  
   //Checks it the QuestionNode is a leaf node.
21  
   public boolean isAnswer(){
22  
      return yes == null && no == null;
23  
   }
24  
}

Author comment

Began life as a copy of #1002517

download  show line numbers   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1002518
Snippet name: Java text game / QuestionNode
Eternal ID of this version: #1002518/1
Text MD5: 41ffc42545fed211e92cd9fa715207e5
Author: stefan
Category:
Type: Java source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-01-29 18:34:58
Source code size: 733 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 758 / 134
Referenced in: [show references]