有两个班
头等舱是
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Collections;
public class Hieracrhy
{
ArrayList<Tutor> Tutor_person=new ArrayList<Tutor>();
public static void main(String[] args)
{
Hieracrhy obj=new Hieracrhy();
obj.start();
}
public void start()
{
getDetails();
System.out.println(Tutor_person);
}
//Function to read the songs from the file
void getDetails()
{
try
{
File file=new File("SongsList.txt");//Represents a file
FileReader fileReader=new FileReader(file);//FileReader connects to a text file
BufferedReader reader=new BufferedReader(fileReader);//For Efficient reading of file
// We use String variable to hold each line when the line is read one-by-one
String line=null;
//Read a line of the string and assign it to a string if it is not null just doo the func
while((line=reader.readLine())!= null)
{
addDetails(line);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
void addDetails(String lineToParse)
{
String[] tokens=lineToParse.split("/");
Tutor nextPerson=new Tutor(tokens[0]);
Tutor_person.add(nextPerson);
}
}
现在还有另一堂课
import java.util.ArrayList;
public class Tutor
{
int Tutor_id;
String Tutor_name;
String Tutor_place;
int Tutor_age;
public void Set_Things_for_Tutor(int Tutor_id,String Tutor_name,String Tutor_place,int Tutor_age)
{
this.Tutor_id=Tutor_id;
this.Tutor_name=Tutor_name;
this.Tutor_place=Tutor_place;
this.Tutor_age=Tutor_age;
}
public int getuserid()
{
return Tutor_id;
}
public String getname()
{
return Tutor_name;
}
public String getdesignation()
{
return Tutor_place;
}
public int getage()
{
return Tutor_age;
}
}
现在在文本文件中有输入
11/devrath/hassan/22
但是当我运行完整的设置时,我得到了错误
构造函数导师(字符串)未定义
这个错误的原因是什么.....有人可以帮我解决这个问题吗?
谢谢