Status: Started
  • Digits.java
  • DigitsTester.java
Font Size
14
Parentheses autocomplete
Wrap lines
Editor
Theme
Code with blocks by default
Console Font Size
12
Console Theme
Display Server Graphics Screen
Show File Tab Bar
Debug Mode
5 Digits Part a (run code)
DigitsTester.java
public class DigitsTester
{
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Output
Grading
Docs
Exercise
More
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Pass Test Message

Errors:

This student is viewing this assignment in English. View this page in English?

5 points

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. 

Reset Code

Slides and Notes

No slides available for this video

About

Java (main)
Java Version 1.8.0_222