为我的 CS 课创建一个程序,基本上一个程序(由我的导师创建)创建了一个制作书名和作者的程序,然后代码将通过我的程序运行,该程序将构建一个 Book Class 和 Author Class 以确保它们可操作我的问题是,在我的书类中调用了作者代码“a3”的第 12 行,我不知道如何在我的第二类构造函数中调用我的第一类。正如我收到一个错误,上面写着“期望三点”。
//my code
public class Author {
String firstName;
String lastName;
//variables
public Author (String a) {
firstName = a;
}
public Author (String a, String b) {
firstName = a;
lastName = b;
}
}
public class Book {
String Title;
String a;
//variables
public Book (String c, Author) {
Title = c;
}
public Book () {
}
}
// instructor's code
void setup() {
Book [] allTheBooks = new Book[30];
int score = 6;
int tScore = 0;
System.out.println( "Attempting constructors:" );
Author a1 = new Author( "Ballard", "J.G." );
Author a2 = new Author( "Eggers", "Dave" );
Author a3 = new Author( "Catton", "Eleanor" );
Author a4 = new Author( "Adler", "Renata" );
System.out.println( " - Author constructors seem functional: 3/3" );
allTheBooks[1] = new Book( "The Circle" );
allTheBooks[2] = new Book( "The Luminaries", a3 );
allTheBooks[3] = new Book();
allTheBooks[4] = new Book( "Pitch Dark" );
allTheBooks[5] = new Book( "Speedboat" );
allTheBooks[6] = new Book();
allTheBooks[7] = new Book( "The Dissident Gardens" );
System.out.println( " - Book constructors seem functional: 3/3" );
}