java - In my "Millionaire" Game Program, the questions are not showing -


i made "who wants millionare" kind of app it's not working. questions , choices not showing. use borderpane contains listview stages($0-$1000000),a gridpane question choices, , 2 hbox es question , start button. here's code.

game

package game;  import javafx.application.application; import javafx.collections.fxcollections; import javafx.collections.observablelist; import javafx.event.actionevent; import javafx.event.eventhandler; import javafx.scene.scene; import javafx.scene.control.button; import javafx.scene.control.listview; import javafx.scene.layout.borderpane; import javafx.scene.layout.gridpane; import javafx.scene.layout.hbox; import javafx.scene.text.text; import javafx.stage.stage;  public class game extends application{     @override     public void start(stage primarystage){         primarystage.settitle("millionare");         question[] questions=new question[14];         string[] questionnames={                 "13425",                 "",                 "",                 "",                 "",                 "",                 "",                 "",                 "",                 "",                 "",                 "",                 "",                 "",                 "",         };         string[][] choices = {                 {"531","22354","33254","53424"},                 {"","","",""},                 {"","","",""},                 {"","","",""},                 {"","","",""},                 {"","","",""},                 {"","","",""},                 {"","","",""},                 {"","","",""},                 {"","","",""},                 {"","","",""},                 {"","","",""},                 {"","","",""},                 {"","","",""},                 {"","","",""},         };         boolean[] rights = {                 false,                 false,                 false,                 false,                 false,                 false,                 false,                 false,                 false,                 false,                 false,                 false,                 false,                 false,                 false,         };         for(int i=0;i<questions.length;i++){             for(int j=0;j<questionnames.length;j++){                 for(int y=0;y<choices.length;y++){                     for(int x=0;x<rights.length;x++)                         questions[i]=new question(questionnames[j],choices[y],rights[x]);                 }              }         }         text question=new text("answer questions win $1,000,000!");         button enter=new button("                                               start                                                           ");         button choice1=new button("choice 1");         button choice2=new button("choice 2");         button choice3=new button("choice 3");         button choice4=new button("choice 4");         observablelist<string> stages = fxcollections.observablearraylist(                 "0",                 "100",                 "200",                 "500",                 "1000",                 "2000",                 "4000",                 "8000",                 "61000",                 "50000",                 "10000",                 "250000",                 "500000",                 "1000000"                 );         listview<string> lv=new listview<>(stages);         hbox hb1=new hbox();         hbox hb2=new hbox();          gridpane gp=new gridpane();         borderpane bp=new borderpane();         hb1.getchildren().add(question);         hb2.getchildren().add(enter);         gp.add(choice1, 1, 3);         gp.add(choice2, 2, 3);         gp.add(choice3, 3, 3);         gp.add(choice4, 4, 3);         enter.setonaction(new eventhandler<actionevent>(){             @override             public void handle(actionevent event) {                 enter.setvisible(false);                 question.settext(questions[0].qstn);                 choice1.settext(questions[0].getchoice(0));                 choice2.settext(questions[0].getchoice(1));                 choice3.settext(questions[0].getchoice(2));                 choice4.settext(questions[0].getchoice(3));             }         });         bp.settop(hb1);         bp.setcenter(gp);         bp.setright(lv);         bp.setbottom(hb2);         scene scene=new scene(bp,724,200);         primarystage.setscene(scene);         primarystage.show();     }     public static void main(string[] args){         launch(args);     } } 

question

package game;  public class question { protected string qstn=""; protected string[] choices = new string[3]; protected boolean win; question(string qstn,string[] choices,boolean win){     this.qstn=qstn;     this.choices=choices;     this.win=win; } protected string getchoice(int i){     return choices[i]; } } 

is working me....

  @override public void start(stage primarystage){     primarystage.settitle("millionare");     question[] questions=new question[14];     string[] questionnames={             "13425",             "13425",             "13425",             "13425",             "13425",             "13425",             "13425",             "13425",             "13425",             "13425",             "13425",             "13425",             "13425",             "13425",             "13425",     };     string[][] choices = {             {"531","22354","33254","53424"},             {"531","22354","33254","53424"},             {"531","22354","33254","53424"},             {"531","22354","33254","53424"},             {"531","22354","33254","53424"},             {"531","22354","33254","53424"},             {"531","22354","33254","53424"},             {"531","22354","33254","53424"},             {"531","22354","33254","53424"},             {"531","22354","33254","53424"},             {"531","22354","33254","53424"},             {"531","22354","33254","53424"},             {"531","22354","33254","53424"},             {"531","22354","33254","53424"},             {"531","22354","33254","53424"},     };     boolean[] rights = {             false,             false,             false,             false,             false,             false,             false,             false,             false,             false,             false,             false,             false,             false,             false,     };     for(int i=0;i<questions.length;i++){         for(int j=0;j<questionnames.length;j++){             for(int y=0;y<choices.length;y++){                 for(int x=0;x<rights.length;x++){                     questions[i]=new question(questionnames[j],choices[y],rights[x]);                 }             }          }     }     text question=new text("answer questions win $1,000,000!");     button enter=new button("                                               start                                                           ");     button choice1=new button("choice 1");     button choice2=new button("choice 2");     button choice3=new button("choice 3");     button choice4=new button("choice 4");     observablelist<string> stages = fxcollections.observablearraylist(             "0",             "100",             "200",             "500",             "1000",             "2000",             "4000",             "8000",             "61000",             "50000",             "10000",             "250000",             "500000",             "1000000"             );     listview<string> lv=new listview<>(stages);     hbox hb1=new hbox();     hbox hb2=new hbox();      gridpane gp=new gridpane();     borderpane bp=new borderpane();     hb1.getchildren().add(question);     hb2.getchildren().add(enter);     gp.add(choice1, 1, 3);     gp.add(choice2, 2, 3);     gp.add(choice3, 3, 3);     gp.add(choice4, 4, 3);     enter.setonaction(new eventhandler<actionevent>(){         @override         public void handle(actionevent event) {             enter.setvisible(false);             question.settext(questions[0].qstn);              choice1.settext(questions[0].getchoice(0));             choice2.settext(questions[0].getchoice(1));             choice3.settext(questions[0].getchoice(2));             choice4.settext(questions[0].getchoice(3));         }     });     bp.settop(hb1);     bp.setcenter(gp);     bp.setright(lv);     bp.setbottom(hb2);     scene scene=new scene(bp,724,200);     primarystage.setscene(scene);     primarystage.show(); } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -