Goals:
• Create classes from scratch (All levels)
• Create a class that represents a mathematical entity (D-level)
• Implement an operation on this entity (C-level)
• Create a collection that represents a higher-level mathematical entity (C-level)
• Implement simplified operations on collection that utilize low-level entity’s methods (B-level)
• Reimplement operation to be more general (A-level)
• Make the low-level class more general (A-level) Overview: In this project, you’ll create numbers from the digits up and possibly extend them to other bases. I will give you some test files for different levels. Note: You may not use Java library functions such as parseInt to do decimal conversions, additions, etc. Documentation in each class file (Digit and DNumber):
• At the top of your file, put a description of the class. Also include your name and the date.
• Before each constructor or method, use a JavaDoc-style comment that describes the constructor or method. See Appendix I on pp. 601-603 for info on JavaDoc.
• Look at ClockDisplay and NumberDisplay for examples. Style: See Appendix J, pp. 605-608 for the Program Style Guide. Follow these rules in your project. Specific Tasks – Creation of Digit Class (D-level) Create a Digit class that represents a decimal digit with the following parts:
• Appropriate field(s)
• A constructor that takes an initial value (an int) as a parameter and requires a legal initial value (0-9). If the initial value is not legal, print an error message and use 0 as the value for the object. (public Digit(int val))
• An accessor method getValue that returns the value of the digit as an int.
• A mutator method setValue that sets the value of the digit if the parameter is a 0-9. If the parameter is not 0-9, the digit should keep the old value.
• A public String toString() method that creates a String of the digit represented (just “0”, “1”, “2”, …, “9”)
Get Free Quote!
356 Experts Online