In this HW, you will begin to practice good modular decomposition and class design. No longer should a program all reside in main(). Instead, you should create different classes in each program, where each class provides one important function. For this assignment in particular, you'll gain practice using conditional statements and you'll create a simple, interactive graphical application for some initial experience with event handling.
On the last two assignments, you began to learn about javadoc, but comments simply focused on class headers. In this assignment, you'll learn about documenting class member variables and methods.
In your class, you should precede each member variable with a javadoc comment that describes how that variable is used by the class. The variables name and completedPasses are examples below. Next, start each method with a comment that tells what that method does, just like you did for the class. Javadoc also recognizes special commands called tags that denote important information for the web page being generated. Two of those tags will be used in method comments.
@param paramName description @return returnValue descriptionFor example, consider the following code:
// Quarterback.java
// Brett Favre (gtg600m)
// Collaboration: I worked on this myself.
import java.util.Random;
/**
* <Description for the whole class>
* @author Brett Favre
* @version 1.0
*/
public class Quarterback {
/** <Description of this member variable> */
private String name;
/** <Description of this member variable> */
private int completedPasses;
/**
* <Description of what this method does>
* @param howFar <Description of first parameter>
* @param numSpirals <Description of second parameter>
* @return <Description of the return value>
*/
public double interception (double howFar, int numSpirals) {
return howFar/completedPasses * numSpirals;
}
}
When doing inventory management, a concern is always that product information be entered correctly. When products have identifiers that are long lists of numbers, this is an especially important concern. One way to better insure that a correct ID is entered is to perform some kind of validation or checking of the ID. The checksum technique tests whether the digits of an ID follow some particular property.
One ID that you are likely familiar with is the Universal Product Code (UPC) that most manufactured items now have. A sample UPC symbol is shown below.
A UPC is a 12-digit value that meets the following criteria:
A special case occurs when r is 10 and the last digit is a zero. You should consider this a match and a valid UPC.
For example, consider the UPC above. Here m = 9 + 1 + 5 + 9 + 0 = 24, n = 7 + 0 + 4 + 1 + 7 + 4 = 23, and r = 10 - ((24 + 69) mod 10) = 10 - (93 mod 10) = 10 -3 = 7. Because r is the same as the 12th (last) digit, then this is a valid code.Your objective is to write a program that prompts the user to enter a numeric value, and then you determine whether that value is a valid UPC number or not. You will be creating a GUI application to accomplish this. You should provide a type-in text field in which the user will enter an integer. You can assume that input is always in the form of a positive integer, but you should think about many different ways that the value will not be a UPC number. The GUI should have a text label that simply states whether the number is a valid UPC symbol or not.
Make sure to decompose your program into different classes in order to help break the problem into manageable pieces, ie, following the principles of encapsulation and modular decomposition.
Requirement: Call your class in which execution begins in main() UPCchecker.
Hint: What's the largest valid java int value?
After you have finished the above assignment, turn it in via Webwork You will very likely be submitting multiple files. Please make sure they are named as shown below: