要求做一个对明星表白的程序,最后两个类不知道怎么用?然后三个程序也不知道是不是调用的对。求大佬们看看第二个语句哪里错了!谢谢
public class Asst3
{
public static void main(String[] args)
{
CelebStalker s=new CelebStalker();
s.play();
}
}
import java.util.Scanner;
import java.util.Random;
public class CelebStalker
{
// final instance variables
// non-final instance variables
int guardPos;
public CelebStalker()
{
// method body
public void explain()
{
// method body
System.out.println("Stalk a Celebraity");
System.out.print("==================");
System.out.println("You have to find and seduce your ideal celebrity. Now.");
}
public void play()
{
// method body
Scanner scan = new Scanner (System.in);
System.out.println("Would you like to play Stalk a Celeb?");
String Choice_Will = scan.nextLine();//change here
if (Choice_Will == True)
{
System.out.println("True/False, do you want to stalk a male celebrity?");
String male = scan.nextLine();
if (male = true)
{
Random rand = new Random();
int Num_Male = rand.nextInt(10);
System.out.println("You are stalking" + celebrity.getCelebrity[Num_Male]);
}
else
{
Random rand = new Random();
int Num_FeMale = rand.nextInt(10);
System.out.println("You are stalking" + celebrity.getCelebrity[Num_FeMale]);
}
int pos_guard;//give random position to guard
Random generator = new Random();
pos_guard = generator.nextInt(numStreets);
while (pos_guard == currentStreet.CelebrityBot)
{
Random generator = new Random();
pos_guard = generator.nextInt(numStreet.CelebrityBot);
}
guardPos = pos_guard;
System.out.println("You are in street #" + currentStreet.CelebrityBot + ".");
//the following part will show to show your love;
Random r1 = new Random();
int Num_Right = r1.nextInt(9);
Random r2 = new Random();
int Num_Left = r2.nextInt(9);
Random r3 = new Random();
int Num_Ahead = r3.nextInt(9);
Random r4 = new Random();
int Num_Behind = r4.nextInt(9);
System.out.println("To your left is #" +left.CelebrityBot[Num_Left] + ",", "to your right is #" + right.CelebrityBot[Num_Right] + "ahead is #" + ahead.CelebrityBot[Num_Ahead] + "and behind is #" + behind.CelebrityBot[Num_Behind]);
}
char ch;//ch is the choice;
System.out.println("Would you like to Walk(w), Shout(s), Reset(r), Quit(q)?");
ch = scan.nextLine();
switch (ch) {
case "s":
//"shout" function is declared later.
int shout;
if (shout == guardPos)
{
int dazed = MAX_DAZED_MOVES.tryWalk;// "dazed" is the time of dazed;
System.out.println("You haved dazed for next two moves.");
if (currentStreet.tryWalk == celePos)
{
System.out.println("Sorry, you are failed to see your star.");
}
else
{
int i = 0;
int h = 0;
if (shout == celePos.CelebrityBot)
{
for(i = 0; i<= 3; i++)
{
char[] outcome = {"SUCCESS", "FAILURE"};
Random r = new Random();
char Outcome_R = r.nextLine(2);
char Outcome_Result = outcome[Outcome_R];
System.out.println("You have declared your love" + i + "/3" + "times and shouted in empty streets" + h + "times.");//print out the random result of shouting to the cele;
}
}
else
{
for(h = 0; h <= 3; h++)
{
System.out.println("You have declared your love" + i + "/3" + "times and shouted in empty streets" + h + "times.");
}
}
}
}
else
{
if (shout == celePos.CelebrityBot)
{
for(i = 0; i<= 3; i++)
{
char[] outcome = {"SUCCESS", "FAILURE"};
Random r = new Random();
char Outcome_R = rand.nextLine(2);
char Outcome_Result = outcome[Outcome_R];
System.out.println("You have declared your love" + i + "/3" + "times and shouted in empty streets" + h + "times.");
}
}
else
{
for(h = 0; h <= 3; h++)
{
System.out.println("You have declared your love" + i + "/3" + "times and shouted in empty streets" + h + "times.");
}
}
}
//"walk" function will be illustrated;
case "w":
System.out.println("Which street would you like to walk into? " + currentStreet.trywalk);
Street_Num = scan.nextInt;
if (Street_Num = nextIs.nextStreet)
{
if (Street_Num = guardPos)
{
System.out.println("Sorry, You are dazed within 2 moves and do not know where you are!");
}
else
{
if (Street_Num = celePos)
{
if (dazedRemaining != 0)
{
System.out.println("Sorry, you are failed!");
}
}
else
{
System.out.println("Walk successfully, but you are still alone!");
//this part should be more statemnet to make it continue;
}
}
}
//"quit" function will be illustrated;
case "q":
System.out.println("Quit Selected");
//"Reset" function will be illstrated;
case "r":
Reset reset = new Reset();
Reset = CelebrityBot.reset;
default :
System.out.println("Impossible Command!");
}
else
{
System.out.println("0 Moves.");
}
}
public void setTracing(boolean onOff)
{
onOff = onOff.setTracing;
tracing = onOff;
}
public void trace(String message)
{
if(tracing)
{
System.out.println("CelebStalker: " + message);
}
}