You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`import java.util.Random;
import java.util.Scanner;
public class VacuumAgent
{
public static char Reflex_Vacuum_Agent(char Location)
{
char otherLoc;//the next destination
char status;// the statues: [clean or dirty]
String input="DC";
int statesNumb=input.length();
Random r = new Random();
status=input.charAt(r.nextInt(statesNumb));//status gets C or D randomly
if(Location=='A')
otherLoc='B';
else
otherLoc='A';
if (status == 'D') { // the location is dirty
System.out.println("\n"+Location+ " [Detected-Dirty], clean and go to the location " + otherLoc);
return otherLoc;
}
if (status=='C') // The location is clean
{
if ( Location == 'A') {
System.out.println("\n"+Location+" [Detected-clean], Action: go to Location B");
return otherLoc; }
else if ( Location == 'B') { System.out.println("\n"+Location+" [Detected-clean], Action: go to Location A");
return otherLoc; }
}
System.out.println("Unexpected failure with detecting the location status,try again");
return Location;
}
public static void main(String []args)
{
int times;//The number of the Agent's actions
String input;
Character Location=new Character(' ');//to keep the agent's location
Scanner userInput=new Scanner(System.in);
System.out.print("Enter the location of the Agent(A[room] or B[room]): ");
input=userInput.nextLine();
Location =input.charAt(0);
if(!(Location.equals('A')||Location.equals('B')) )//check the correct input of the location
{
System.out.println("The location is wrong, run the program again");
System.exit(0);
}
System.out.println("The Agent starts at: " + Location);
System.out.println("Enter the number of the Agaent's actions: ");
times=userInput.nextInt();
int counter=0;
while ((counter++)!=times) {
Location=Reflex_Vacuum_Agent(Location);
}
}
}`
the error
Main.java:3: error: class VacuumAgent is public, should be declared in a file named VacuumAgent.java
public class VacuumAgent
^
Note: Main.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
No description provided.
The text was updated successfully, but these errors were encountered: