我有这段代码
> read.xlsx("Book1.xlsx", a[2])
Error in read.xlsx.default("Book1.xlsx", a[2]) :
Cannot find sheet named "S&P500 TR"
简单地说,我希望它在字符串写出正确的句子时停止循环随机值,在这种情况下它是“我爱你”。我需要添加什么才能使其停止,以便W1 [0] W2 [1]等。
如果重要的话,使用Processing来编写它。
答案 0 :(得分:0)
这应该有用,但我从未使用过Processing,所以我不确定你的原始代码有多正确。
void draw() {
//I love you sentance
String[] W1 = {
"I", "love", "you", "."
};
String[] W2 = {
"I", "love", "you", "."
};
String[] W3 = {
"I", "love", "you", "."
};
String[] W4 = {
"I", "love", "you", "."
};
String Sentence = "";
while (!Sentence.equals("I love you .")) {//the last space is required
int w1 = int(random(W1.length));
int w2 = int(random(W2.length));
int w3 = int(random(W3.length));
int w4 = int(random(W4.length));
Sentence = W1[w1]+" "+W2[w2]+" "+W3[w3]+" "+W4[w4];
println(Sentence);
background(239,238,238);
textAlign(CENTER);
textFont(f);
fill(66,134,244);
text(Sentence, 0.5*displayWidth, 0.5*displayHeight+25);
delay(1000);
}
}