Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment #6 CSE110- Arizona State University Topics Arrays Classes Coding Guidelines: . Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay,

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Assignment #6 CSE110- Arizona State University Topics Arrays Classes Coding Guidelines: . Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, ete). Keep identifiers to a reasonably short length. . User upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for all other identifiers (variables, methods, objects). . Use tabs or spaces to indent code within blocks (code surrounded by braces). This includes classes methods, and code associated with ifs, switches and loops. Be consistent with the number of spaces or tabs that you use to indent . Use white space to make your program more readable. Part #1 -Programming Your assignment is to create a class called NumberCollection in a file called NumberCollection.java (there is no nain method in this class). The NunberCollection class will act as a resizable array of unique integers and provide methods to act on the collection. Therefore the NunberCollection class needs the following instance variables: numberArray an array of integers to hold the collection. . count an int to hold how many integers have been stored in the array so far Note: The instance variable count will usually be different than the capacity of the array (numberArray.length) In order to provide access to the collection, the class NunberCollection must include the following con- structor and methods. (If your class does not contain any of the following methods, points will be deducted.) . public NumberCollection(int arraySize) It coastructs an empty NumberCollection object with an array capacity specified by the integer parameter arraySize. That is, it stores a new int array with size arraySize in the nunberArray instance variable .private int indexOf (int searchingNum) It returns the index of the number specified by the paranieter is located. If the number is not found, it retums-IThis i, a helper method. public boolean addNumber (int numberToAdd). Te method will add nunberToAdd at the smallest available index in the array, if the number is not in already in the array. Be sure to check if the number is already in the array Hint: This can be done using the indexOf method to see if it returns -1 or not

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

Students also viewed these Databases questions

Question

What is a churn and how does it affect a firm?

Answered: 1 week ago

Question

Complexity of linear search is O ( n ) . Your answer: True False

Answered: 1 week ago