我正在尝试复制我已经创建的 BookOrder,但是,它没有正确创建。到目前为止,我有这个。
public class BookOrder
{
private String author;
private String title;
private int quantity;
private double costPerBook;
private String orderDate;
private double weight;
private char type; //R,O,F,U,N
public BookOrder (String author, String title)
{
}
public BookOrder(String author, String title, int quantity, double costPerBook, String orderDate, double weight, char type)
{
this.author= author;
this.title= title;
this.quantity= quantity;
this.costPerBook= costPerBook;
this.orderDate= orderDate;
this.weight= weight;
this.type=type;
}
public BookOrder(BookOrder bookOrder)
{
}
但是,当我尝试在此处复制时:
public class TestBookOrder
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
Utility.myInfo("11/5,2013", "Project4");
Utility.pressEnterToContinue();
Utility.clearScreen();
BookOrder BookOrder1 = new BookOrder("Jonathan", "Book1", 12, 6.75, "11/5/2013", 8.75, 'r');
System.out.print(""+ BookOrder1.invoice());
BookOrder copyA = new BookOrder(BookOrder1);
BookOrder copyB= new BookOrder(BookOrder1);
copyB.adjustQuantity(-5);
System.out.print("\n"+ copyB.invoice());
System.out.print("\n"+ copyA.invoice());
}
}
它只是将 copyA 和 copyB 的发票返回为 null 和 0。任何人都知道 copy 方法中需要包含哪些代码?