我是新手,我弄清楚了除一部分以外的所有代码。假广播电台我需要显示一种方法,该方法包含已发现为真的方法下面的消息。
if (seek.equals("down")) {
for (int i = 0; i <= 10; i++) {
int rmdTest = rmd.nextInt(10);
found = rmdTest > 6;
if (found) {
if (rmdTest == 7)
foundStation(98.9, found);
if (rmdTest == 8)
foundStation(100.3, found);
if (rmdTest == 9)
foundStation(107.9, found);
//This prints out that station is found, but it needs
//message that displays the callsign/what's playing
我不完全理解这个问题,但是认为您将从更多的OOP方法中受益,例如:
Radio radio = new Radio();
Station station = radio.getCurrentStation();
Callsign callsign = station.getCallsign();
以这种方式,问题的“发现为真”部分由getCurrentStation
处理,而“消息不足”部分位于getCallsign
或显示所需的任何格式的消息中,也许是诸如display.show(callsign)
之类的更新方法或最好是事件驱动。