我是一个超级初学者程序员,我正在制作一个简单的应用程序,它根据高中项目的输入选择猴子(gog)。我查过这个问题,所有的答案似乎都是针对具体情况的,或者超出了我的理解范围,所以 ELI5 的答案将不胜感激。这是我的代码供参考:
//variables
var bananas;
var color;
var size;
//updates color on click
onEvent("colorDD", "click", function( ) {
updateScreen();
});
//updates size on click
onEvent("sizeDD", "click", function( ) {
updateScreen();
});
//updates bananas consumed on slider move
onEvent("bananaSlider", "mousemove", function( ) {
updateScreen();
});
//Updates the screen with all info including bananas, color, and size to display Gog image
function updateScreen() {
//color storer
color = getText("colorDD");
//size storer
size = getText("sizeDD");
//banana storer
bananas = getNumber("bananaSlider");
//If statement for bottom text
if (color == "Red" && bananas == 10 && size == "Big"){ // Big Red Gogs
setText("feedbackOutput", "Gog -1?!?!?!");
setImageURL("gog", "gog-1.gif");
} else if ( color == "Red" && size == "Big" && bananas < 5){
setText("feedbackOutput", "You are Gog 720!");
setImageURL("gog", "gog720.gif");
} else if ( color == "Red" && size == "Big"){
setText("feedbackOutput", "You are Gog 6!");
setImageURL("gog", "gog6.gif");
} else if ( color == "Red" && size == "Medium" && bananas > 6){ // Medium Red Gogs
setText("feedbackOutput", "You are Gog 51!");
setImageURL("gog", "gog51pog-min.gif");
} else if ( color == "Red" && size == "Medium" && bananas < 4){
setText("feedbackOutput", "You are Gog 5!");
setImageURL("gog", "gog5.gif");
}
可以看出,有香蕉、颜色和大小三个变量,为每个变量选择特定值将在屏幕上给出不同的图像。
回首忆惘然
慕森王
皈依舞
相关分类