- Digits.java
- DigitsTester.java
Grader Results
x/x
Pass | Test | Message | |
---|---|---|---|
- | Test results will show here. | - |
Errors:
This question involves identifying and processing the digits of a non-negative integer. The declaration of the Digits class is shown below. You will write the constructor and one method for the Digits class.
public class Digits
{
/** The list of digits from the number used to construct this object.
* The digits appear in the list in the same order in which they appear in the original number.
*/
private ArrayList<Integer> digitList;
/** Constructs a Digits object that represents num.
* Precondition: num >= 0
*/
public Digits(int num)
{ /* to be implemented in part (a) */ }
/** Returns true if the digits in this Digits object are in strictly increasing order;
. * false otherwise.
*/
public boolean isStrictlyIncreasing()
{ /* to be implemented in part (b) */ }
}
Part A:
Write the constructor for the Digits class. The constructor initializes and fills digitList with the digits from the non-negative integer num. The elements in digitList must be Integer objects representing single digits, and appear in the same order as the digits in num. Each of the following examples shows the declaration of a Digits object and the contents of digitList as initialized by the constructor.
Complete the Digits constructor.
This question involves identifying and processing the digits of a non-negative integer. The declaration of the Digits class is shown below. You will write the constructor and one method for the Digits class.
public class Digits
{
/** The list of digits from the number used to construct this object.
* The digits appear in the list in the same order in which they appear in the original number.
*/
private ArrayList<Integer> digitList;
/** Constructs a Digits object that represents num.
* Precondition: num >= 0
*/
public Digits(int num)
{ /* to be implemented in part (a) */ }
/** Returns true if the digits in this Digits object are in strictly increasing order;
. * false otherwise.
*/
public boolean isStrictlyIncreasing()
{ /* to be implemented in part (b) */ }
}
Part A:
Write the constructor for the Digits class. The constructor initializes and fills digitList with the digits from the non-negative integer num. The elements in digitList must be Integer objects representing single digits, and appear in the same order as the digits in num. Each of the following examples shows the declaration of a Digits object and the contents of digitList as initialized by the constructor.
Complete the Digits constructor.
Upload an image
Upload from your computer
Or paste a link here
Slides and Notes
No slides available for this video
About
Java (main)
Java Version 1.8.0_222