Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

help me to finish those 2 question int[] data = {}; //data array store digits in this natural number /** * THIS IS A HELPER

help me to finish those 2 question

int[] data = {}; //data array store digits in this natural number

/**

* THIS IS A HELPER method which converses a digit character to its integer value.

* @param c is character and assumed be one of the following '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'

* @return an integer value of character in c

*/

private int toInt(char c)

{

return (int)c - (int)'0';

}

/**

* A parameterized constructor

* @param initData is a String containing the digits of this NaturalNumber

* instantiate the data array to correct size and store the digits from initData

* as an integer in array data.

*

* The constructor should use its setter to set each digit to

*/

public NaturalNumber(String initData)

{

// write code

return;

}

/**

* A setter : setting an integer between 0 to 9 to a digit specified by parameter digitIndex to the data array

* @param digitIndex is the index to data array

* @param value is an integer between 0 and 9

*

* setter validation:

* @param digitIndex must be between 0 and data.length - 1 AND @param value must be between 0 and 9

* otherwise, this setter should not do anything to the data array.

*/

public void setDigit(int digitIndex, int value)

{

//write code

return;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions