I’m wondering why my main method doesn’t recognize my other methods? Im using Geany, (we’re supposed to for school) and it will autofill the method I am trying to call, but I get a “cannot find symbol java52” error when I try to compile. Why is this? Everything else has been working fine.
I have three classes thus far.
Here is my driver class. This is the one thats having issues. I included the other classes so that you guys can have all the information.
import java.util.Scanner;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
public class LibraryCollectionManager
{public static void main (String args)
{
int quitVal = 0; //variable used to pass to end program
int patronCount = 0; //used to keep track of patrons so that arrays can be managed correctly
String choice = “blank”; //varaible to represent menu choices
Scanner input = new Scanner(System.in);
while (quitVal == 0)
{launchMenu(); System.out.print("Make a choice by typing the value in parenthesis. \n Ex : Choice (val), type >val. : "); choice = input.nextLine(); switch (choice.toLowerCase()){ case "a1" : System.out.println("DEBUG: You chose to display all materials"); break; case "a2" : System.out.println("DEBUG: You chose to search by author"); break; case "a3" : System.out.println("DEBUG: You chose to search by title"); break; case "a4" : System.out.println("DEBUG: You chose to search by type"); break; case "a5" : System.out.println("DEBUG: You chose to Checkout a material"); break; case "a6" : System.out.println("DEBUG: You chose to Return a checked out material"); break; case "a7" : System.out.println("DEBUG: You chose to Display all overdue materials"); break; case "a8" : System.out.println("DEBUG: You chose to Add a material"); break; case "a9" : System.out.println("DEBUG: You chose to Remove a material"); break; case "b1" : System.out.println("DEBUG: You chose to Display all patrons"); displayPatrons(); //this is where I am having issues or at least what java is complaining about break; case "b2" : System.out.println("DEBUG: You chose to Display all patrons with overdue >materials "); break; case "b3" : System.out.println("DEBUG: You chose to Add a new patron"); break; case "b4" : System.out.println("DEBUG: You chose to Remove a patron "); break; case "c1" : System.out.println("DEBUG: You chose to Load Data from File "); break; case "c2" : System.out.println("DEBUG: You chose to Save Data to File"); break; case "d4" : System.out.println("DEBUG: You chose to quit"); quitVal++; break; } }
}//end of main
public static void launchMenu()
{
Scanner inputFile = null;
//Try to open the file
try
{
inputFile = new Scanner(new FileInputStream(“menu.txt”));
}
catch(FileNotFoundException e)
{
System.out.println(“Could not find or open file”);
}do { System.out.println(inputFile.nextLine()); }while (inputFile.hasNextLine());
}
}//end of FinalProject class
Here is my patron method class, it contains the methods I am trying to call
import java.util.Scanner;
public class PatronCollection
{
//instance variables
int collectionMaxSize;
PatronpatronCollection;public void displayPatrons()
{
for (int i = 0; i < patronCollection.length; i++)
{
System.out.println(patronCollection[i].toString() );
}
}public Patron addPatron(Patron patronCollection, int patronCount)
{
Scanner input = new Scanner(System.in);
System.out.print(" \n Enter name of new patron : “);
String name = input.nextLine();
System.out.print(” \n Enter ID of new patron : ");
String id = input.nextLine();Patron patron = new Patron(id, name); patronCollection[patronCount] = patron; patronCount++; return patronCollection;
}
} // end of PatronCollection class
Then here is my patron class, it contains the information on patrons as an object
public class Patron
{
//instance variable
String id;
String name;
//constructor methods
public Patron()
{
System.out.println(“There is no information given on this patron…”);
}
public Patron(String id)
{
this.id = id;
}
public Patron(String id, String name)
{
this(id);
this.name = name;
}
//getter and setter methods
public String getID()
{
return id;
}
public void setPatronID(String inputID)
{
this.id = inputID;
}
public String getName()
{
return name;
}
public void setName(String inputName)
{
this.name = inputName;
}
//copy constructor
public Patron (Patron inputPatron )
{
//copies instance variables
name = inputPatron.getName(); //copies product name
id = inputPatron.getID(); // copies product price
}
public String toString()
{return " PATRON , " + id + " , " + name ;
}
//equals method
public boolean equals (Patron inputPatron)
{
if ((id.equals(inputPatron.getID())) && (name.equals(inputPatron.getName())) ) //compares all instance variables
{
return true;
}
else
{
return false;
}
}
}//end of patron class
Thank you!