Work with API documentation Review the existing javadoc comments for two busines
ID: 3792626 • Letter: W
Question
Work with API documentation
Review the existing javadoc comments for two business classes
l. Import the project named ch 13 Lineltem that's stored in the ex-starts
2- open the Product class that's in the murach.business package. Then, view the javadoc comments for this class, Note that this class contains javadoc comments that don't includ the @eparam or @return tag
This is the product class file
package murach.business;
import java.text.NumberFormat;
/**
* The <code>Product</code> class defines a product and is used
* by the <code>LineItem</code> and <code>ProductDB</code> classes.
* @author Joel Murach
* @version 8.0
*/
public class Product {
private String code;
private String description;
private double price;
/**
* Creates a <code>Product</code> with default values.
*/
public Product() {
code = "";
description = "";
price = 0;
}
/**
* Sets the product code.
*/
public void setCode(String code) {
this.code = code;
}
/**
* Gets the product code.
*/
public String getCode() {
return code;
}
/**
* Sets the product description.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Gets the product description.
*/
public String getDescription() {
return description;
}
/**
* Sets the product price.
*/
public void setPrice(double price) {
this.price = price;
}
/**
* Gets the product price.
*/
public double getPrice() {
return price;
}
/**
* Gets the product price with currency formatting.
*/
public String getPriceFormatted() {
NumberFormat currency = NumberFormat.getCurrencyInstance();
return currency.format(price);
}
/**
* Gets the default string for the product.
*/
@Override
public String toString() {
return description;
}
}
3- open the Lineltem class that's in the murach,business package. Note that this class only includes a single javadoc comment at the beginning of this class.
this is the LineItem file
package murach.business;
import java.text.NumberFormat;
/**
* The <code>LineItem</code> class defines a line item.
* This class uses the <code>Product</code> class.
*/
public class LineItem {
private Product product;
private int quantity;
public LineItem() {
this.product = null;
this.quantity = 0;
}
public LineItem(Product product, int quantity) {
this.product = product;
this.quantity = quantity;
}
public void setProduct(Product product) {
this.product = product;
}
public Product getProduct() {
return product;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public int getQuantity() {
return quantity;
}
public double getTotal() {
double total = quantity * product.getPrice();
return total;
}
public String getTotalFormatted() {
double total = this.getTotal();
NumberFormat currency = NumberFormat.getCurrencyInstance();
String totalFormatted = currency.format(total);
return totalFormatted;
}
}
Generate and view the API documentation
4, Generate the documentation for the project. open in a browser by navigating to the doc for the project and opening the index.html page. can open it in Eclipse by double-clicking on the index.html file in the doc folder of the Package Explorer.
5. view the documentation for the Product class. To do that, click on the link fo the murach business package. Then, click on the link for the Product class. Note that it includes descriptions of its constructors and methods.
6. View the details for the getCode and setCode methods. To do that, click on the links for these methods. Note that these methods don't include information about the parameters and return values,
7- View the documention for the Lineltem class by clicking on the link for the Lineltem class. Note that it doesn't include descriptions of its constructors and methods
Improve the javadoc comments
8- Open the Product class. Modify the javadoc comments for this class so they include @param and @retum tags wherever those tags are appropriate
9. Open the Lineltem class, Add javadoc comments to all public constructors and methods using the @param and a return tags wherever those tags are appropriate
Generate and view the improved API documentation
10, Generate the documentation for the project again.
11- View the documentation for the Product and Lineltem classes again. This time, this documentation should include descriptions for all of the constructors methods as well as information about all parameters and retun values For example, the second constructor of the Lineltem class should include information about both of its parameters.
Explanation / Answer
I am answering first four questions for you:
1) Importing lineItem class :
import murach.business.lineItem.*;
2) open the Product class that's in the murach.business package. Then, view the javadoc comments for this class:
javadoc -d docFolder -author -version packageName
here docFolder is where we want to keep extracted comments
3) open the Lineltem class that's in the murach,business package :
select Window -> show view -> javadoc
then in the javadoc view, right click -> open attached javadoc
4) Generate the documentation for the project :
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.