0
因此,我已被分配到一個程序,可以將潛在客戶詳細信息保存在汽車展廳中。因此,我將其分爲三個模塊/類,得到這個,請幫助我。錯誤:無法找到符號[編譯錯誤]無法調用另一個類
package CarSales;
import java.io.Console;
import java.sql.*;
import java.util.Scanner;
public class Startup
{
static public void main(String args[])
{
try{
Monitor mainmon=new Monitor();
Admin mainadm=new Admin();
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/carsales","root","pass");
Statement mainst1=con.createStatement();
Scanner mainscn=new Scanner(System.in);
String roll=null,Pass=null;
String mainchoice;
do
{
System.out.println("Enter your login Id");
String Log_in=mainscn.next();
ResultSet mainrs=mainst1.executeQuery("select Role,Password from login where login_id =\""+Log_in+"\"");
while(mainrs.next())
{
roll=mainrs.getString("Role");
Pass=mainrs.getString("Password");
}
System.out.println("Enter your password");
Console c=System.console();
String mainpass=new String(c.readPassword());
if(mainpass.equals(Pass))
{
System.out.println("Authentic Login");
if(roll.equals("Administrator"))
{
mainadm.calladm();
}
else if(roll.equals("Monitor"))
{
mainmon.callmon();
}
}
else
System.out.println("Wrong Password");
System.out.println("Do you wish to use another account(Y/N)");
mainchoice=mainscn.next();
}while(mainchoice.equalsIgnoreCase("Y")==true);
}catch(Exception e){
e.printStackTrace();}
}
}`
這是主要的類
import java.sql.*;
import java.util.Scanner;
public class Monitor
{
public void callmon() throws Exception
{
String monchoice="Y";
Scanner monscn0=new Scanner(System.in);
do
{
Monitor monobj0=new Monitor();
System.out.println("Welcome Monitor\n1.Add new prospect\n2.Update prospect details\n3.View all prospects(Press number key)");
int menu=monscn0.nextInt();
switch(menu)
{
case 1:
monobj0.add();
break;
case 2:
monobj0.update();
break;
case 3:
monobj0.view();
break;
default:
break;
}
}while(monchoice.equalsIgnoreCase("Y")==true);
System.out.println("Do you wish to continue(Y/N)");
monchoice=monscn0.next();
}
這是顯示器類的w/o的fxns,因爲它們不會在找到誤差neccesary。
import java.sql.*;
import java.util.Scanner;
import java.io.Console;
public class Admin
{
public void calladm() throws Exception
{
String c;
do
{
Admin admobj0=new Admin();
System.out.println("Welcome Administrator. Enter your choice\n1.Modify Accounts 2.View all Monitor Accounts\n3.Search/View Prospects 4.Delete Prospect Record");
Scanner admscn0=new Scanner(System.in);
int var0=admscn0.nextInt();
switch(var0)
{
case 1:
admobj0.modify();
break;
case 2:
admobj0.viewmon();
break;
case 3:
admobj0.viewpro();
break;
case 4:
admobj0.deletepro();
break;
default:
break;
}
System.out.println("Do you wish to continue");
c=admscn0.next();
}while(c.equalsIgnoreCase("Y")==true);
}
這是管理類W/O的fxns ...
Startup.java:10: error: cannot find symbol
Monitor mainmon=new Monitor();
^
symbol: class Monitor
location: class Startup
Startup.java:10: error: cannot find symbol
Monitor mainmon=new Monitor();
^
symbol: class Monitor
location: class Startup
Startup.java:11: error: cannot find symbol
Admin mainadm=new Admin();
^
symbol: class Admin
location: class Startup
Startup.java:11: error: cannot find symbol
Admin mainadm=new Admin();
^
symbol: class Admin
location: class Startup
4 errors
這是我的錯誤,每次我編譯Startup.java 其他人已經進行了編譯。