Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create class called PracticeSet Class should always keep the values in the set i

ID: 3744553 • Letter: C

Question

Create class called PracticeSet
Class should always keep the values in the set in sorted order
When the values of a set are changed, re-sort the values
One data field called set, no getters or setters
Default constructor that creates empty array
Second constructor accepts comma separated list of integers and/or array of integers
Ex: PracticeSet set1 = new PracticeSet(1, 2, 3);
method exists(), should be public with one integer as an argument and return true or false if given value exists in set
method add(), should be public with one integer as an argument and add one integer to set if value doesnt already exist

Explanation / Answer

public class PracticeSet { private int[] set; public PracticeSet() { set = new int[0]; } public PracticeSet(int... arr) { set = new int[arr.length]; for(int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote