java 如何在一个类中显示出另外两个类的方法
classEnrolment{publicstaticvoidmain(String[]args){System.out.println("/*-------------...
class Enrolment{
public static void main(String[] args)
{
System.out.println("/*-------------------------------------");
System.out.println("My name: ");
System.out.println("My student number: ");
System.out.println("My email address: ");
System.out.println("Assignment number: 2");
System.out.println("-------------------------------------*/");
}
}
public class Student {
private final String fullname;
private final String email;
private final String course;
private final int studentNumber;
public Student() throws IOException {
writeStudent();
Scanner inStream = new Scanner(new File("student1.txt"));
fullname = inStream.next();
email = inStream.next();
course = inStream.next();
studentNumber = inStream.nextInt();
inStream.close();
}
private void writeStudent() throws FileNotFoundException {
Formatter outStream = new Formatter(new File("student1.txt"));
outStream.format("%s %s %s %i", "David Black", "davblk@ipw.edu.au", "1853E", 375428);
outStream.close();
}
public void displayStudInfo() {
System.out.print("\nStudent " + fullname + email + course + studentNumber);
}
}
public class Subject {
private final String subjectcode;
private final String session;
private final int year;
public Student() throws IOException {
writeSubject();
Scanner inStream = new Scanner(new File("subject1.txt"));
subjectcode = inStream.next();
session = inStream.next();
year = inStream.nextInt();
inStream.close();
}
private void writeStudent() throws FileNotFoundException {
Formatter outStream = new Formatter(new File("ubject1.txt"));
outStream.format("%s %s %i", "CSIT455", "Autumn", 2017);
outStream.close();
}
public void displaySubjectInfo() {
System.out.print("\nEnrolment " + subjectcode + session + year);
}
}
这是代码 想要在class Enrolment里面展示出其他两个类最后display的内容 展开
public static void main(String[] args)
{
System.out.println("/*-------------------------------------");
System.out.println("My name: ");
System.out.println("My student number: ");
System.out.println("My email address: ");
System.out.println("Assignment number: 2");
System.out.println("-------------------------------------*/");
}
}
public class Student {
private final String fullname;
private final String email;
private final String course;
private final int studentNumber;
public Student() throws IOException {
writeStudent();
Scanner inStream = new Scanner(new File("student1.txt"));
fullname = inStream.next();
email = inStream.next();
course = inStream.next();
studentNumber = inStream.nextInt();
inStream.close();
}
private void writeStudent() throws FileNotFoundException {
Formatter outStream = new Formatter(new File("student1.txt"));
outStream.format("%s %s %s %i", "David Black", "davblk@ipw.edu.au", "1853E", 375428);
outStream.close();
}
public void displayStudInfo() {
System.out.print("\nStudent " + fullname + email + course + studentNumber);
}
}
public class Subject {
private final String subjectcode;
private final String session;
private final int year;
public Student() throws IOException {
writeSubject();
Scanner inStream = new Scanner(new File("subject1.txt"));
subjectcode = inStream.next();
session = inStream.next();
year = inStream.nextInt();
inStream.close();
}
private void writeStudent() throws FileNotFoundException {
Formatter outStream = new Formatter(new File("ubject1.txt"));
outStream.format("%s %s %i", "CSIT455", "Autumn", 2017);
outStream.close();
}
public void displaySubjectInfo() {
System.out.print("\nEnrolment " + subjectcode + session + year);
}
}
这是代码 想要在class Enrolment里面展示出其他两个类最后display的内容 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |