📄 lineitem.java
字号:
package examples;
import java.sql.*;
import javax.naming.*;
import javax.ejb.*;
import java.util.*;
import java.rmi.RemoteException;
import javax.naming.*;
/**
* A lineitem is a quantity of a single Book.
* Many line-items together form an entire order or cart.
*/
public class LineItem implements java.io.Serializable {
/*
* BookItem has Book id, name of the Book and description
*/
public BookItem bookItem;
/*
* Number of items
*/
public int quantity;
/*
* Amount of the discount for each item
*/
public double discount;
//------------------------------------------------
// Begin business methods
//------------------------------------------------
/**
* Constructor
* @param bookitem
* @param number of items
* @Param discount for each item
*/
public LineItem(BookItem bookItem, int quantity, double discount) {
System.out.println("LineItem(...) called");
this.bookItem = bookItem;
this.quantity = quantity;
this.discount = discount;
}
/**
* Constructor
*/
public LineItem() {
System.out.println("New LineItem created.");
}
/**
* Returns the Bookitem.
* Bookitem has Book id, name of the Book and description
*/
public BookItem getBookItem() {
System.out.println("LineItem.getBook() called.");
return bookItem;
}
/**
* sets the Bookitem.
* Bookitem has Book id, name of the Book and description
**/
public void setBook(BookItem bookItem) {
System.out.println("LineItem.setBook() called.");
this.bookItem = bookItem;
}
/**
* Returns the number of items.
**/
public int getQuantity() {
System.out.println("LineItem.getQuantity() called.");
return quantity;
}
/**
* Sets the number of items.
**/
public void setQuantity(int quantity) {
System.out.println("LineItem.setQuantity() called.");
this.quantity = quantity;
}
/**
* Returns the base price. The base price is the
* Book's price times the quantity ordered. This
* figure does not take discounts into consideration.
*/
public double getBasePrice() {
System.out.println("LineItem.getBasePrice() called.");
return quantity * bookItem.getBasePrice();
}
/**
* Returns the discount that the customer gets on
* this order.
*
* Note: The discount is a whole number, not
* a percentage discount.
*/
public double getDiscount() {
System.out.println("LineItem.getDiscount() called.");
return discount;
}
/**
* Sets the discount that the customer gets on
* this order.
*
* Note: The discount is a whole number, not
* a percentage discount.
*/
public void setDiscount(double discount) {
System.out.println("LineItem.setDiscount() called.");
this.discount = discount;
}
//------------------------------------------------
// End business methods
//------------------------------------------------
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -