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

//QuestionNodes have a String data field as well as a reference to two other QuestionNodes.
public class QuestionNode{

   public String data;
   public QuestionNode yes;
   public QuestionNode no;
   
   //Constructs a new QuestionNode with no references so it is a leaf node.
   public QuestionNode(String data){
      this(data, null, null);
   }
   
   //Constructs a QuestionNode with references to the two specifified QuestionNodes.
   public QuestionNode(String data, QuestionNode yes, QuestionNode no){
      this.data = data;
      this.yes = yes;
      this.no = no;
   }
   
   //Checks it the QuestionNode is a leaf node.
   public boolean isAnswer(){
      return yes == null && no == null;
   }
}

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: 822 / 153
Referenced in: #3000382 - Answer for ferdie (>> t = 1, f = 0)