Homework Solution: 1) Polish the class that you proposed as your problem statement….

    Has to be in Java (Bluejay) 1) Polish the class that you proposed as your problem statement. (1.5 points) at least 3 instance variables of different types (e.g., String, int, double, boolean, etc). (1.5 points) a default constructor that is composed of a sequence of this.set() methods. (1.5 points) a custom constructor that is composed of a sequence of this.set() methods. (1.5 points) a get() method for each instance variable (1.5 points) a set() method for each instance variable. Each set() method uses the this keyword. (1.5 points) a toString() method 2) Write a Tester for your class that sets up a data set each of whose elements is of your class’ type. Your tester must meet the following requirements (1 point) Instantiates an array of a certain size – e.g, 10 elements (like in the reference code) (2 points) Takes user input to populate the array (2 points) Uses a do-while loop and a switch statement (like we did in a previous lab) to ask the user what they want to do with the data (6 points @ 1.5 points each) Has at least four options that will correctly handle the user’s selection when called. Option 1: Search the array for objects that meet a search criterion. Display the objects if found. Option 2: Replace an object at a given index with another object. Option 3: Allow the user to select an element from the array and then modify the element (e.g., select a person from the array of persons and then sets the name of that person to a new value). Option 4: Sort the array of objects according to a given criterion (e.g., sort the array of persons by height). Option 5: Exit the program.

    Expert Answer

    Solution 1:

    Has to be in Java (Bluejay)

    1) Make-glossy the systematize that you designed as your substance assertion.

    (1.5 sharp-ends) at meanest 3 precedence fickles of irrelative marks (e.g., String, int, enfold, boolean, etc).

    (1.5 sharp-ends) a deficiency committer that is secure of a order of this.set() orders.

    (1.5 sharp-ends) a usepoch committer that is secure of a order of this.set() orders.

    (1.5 sharp-ends) a attain() order restraint each precedence fickle

    (1.5 sharp-ends) a established() order restraint each precedence fickle. Each established() order uses the this keyword.

    (1.5 sharp-ends) a toString() order

    2) Write a Tester restraint your systematize that establisheds up a postulates established each of whose parts is of your systematize’ mark. Your tester must coalesce the aftercited requirements

    (1 sharp-end) Instantiates an deck of a fixed extent – e.g, 10 parts (affect in the intimation jurisdiction)

    (2 sharp-ends) Takes user input to populate the deck

    (2 sharp-ends) Uses a do-while loop and a switch assertion (affect we did in a prior lab) to implore the user what they deficiency to do with the postulates

    (6 sharp-ends @ 1.5 sharp-ends each) Has at meanest impure options that achieve unexceptionably touch the user’s preoption when indicated.

    Option 1: Quest the deck restraint views that coalesce a quest touchstone. Display the views if build.

    Option 2: Reinstate an view at a consecrated condemnation with another view.

    Option 3: Allow the user to chosen an part from the deck and then variegate the part (e.g., chosen a special from the deck of specials and then establisheds the indicate of that special to a novel rate).

    Option 4: Designation the deck of views according to a consecrated touchstundivided (e.g., designation the deck of specials by tallness).

    Option 5: Departure the program.

    Expert Apology


    Solution 1:

    “Make-glossy the systematize that you designed as your substance assertion.”

    Please stipulate the systematize to be improved ( or make-glossy)

    Solution 2:

    Please perceive the implementation:

    Assumptions: Since here in the substance assertion ‘Person’ is held as in so a deficiency implementation with some postulates members is used to total the Tester systematize of Q2.

    PersonSample.java [Person]

    import java.util.Comparator;

    public systematize SpecialSample {

    private String indicate;
    private int epoch;
    private enfold tallness;

    //Parameterized Committer
    public SpecialSample(String indicate, int epoch, enfold tallness) {
    this.indicate = indicate;
    this.epoch = epoch;
    this.tallness = tallness;
    //Respective attainter() and establishedter()

    public String attainName() {
    return indicate;
    public ineffectual establishedName(String indicate) {
    this.indicate = indicate;
    public int attainAge() {
    return epoch;
    public ineffectual establishedAge(int epoch) {
    this.epoch = epoch;
    public enfold attainHeight() {
    return tallness;
    public ineffectual establishedHeight(enfold tallness) {
    this.tallness = tallness;

    //hasCode() and equals() restraint comparing views restraint eg: quest
    public int hashCode() {
    final int superexcellent = 31;
    int issue = 1;
    issue = superexcellent * issue + ((indicate == ineffectual) ? 0 : indicate.hashCode());
    return issue;

    public boolean equals(View obj) {
    if (this == obj)
    return true;
    if (obj == ineffectual)
    return false;
    if (getClass() != obj.getClass())
    return false;
    PersonSample other = (PersonSample) obj;
    if (indicate == ineffectual) {
    if (other.indicate != ineffectual)
    return false;
    } else if (!name.equals(other.name))
    return false;
    return true;

    //Comparators restraint designationing on the consecrated touchstone
    static Comparator<PersonSample> indicateComparator = Comparator.comparing(PersonSample :: attainName);
    static Comparator<PersonSample> epochComparator = Comparator.comparing(PersonSample :: attainAge);
    static Comparator<PersonSample> tallnessComparator = Comparator.comparing(PersonSample :: attainHeight);

    public String toString() {
    return “PersonSample [name=” + indicate + “, epoch=” + epoch + “, tallness=” + tallness + “]”;



    import java.util.Arrays;
    import java.util.Collections;
    import java.util.List;
    import java.util.Scanner;

    public systematize DeckOptions {

    static SpecialSample[] specialDeck = novel SpecialSample[10];

    public static SpecialSample takeUserInput(){
    System.out.println(“Invade details of special in the aftercited order [Name, Epoch, Tallness]: “);
    Scanner scanner = novel Scanner(System.in);
    String indicate = scanner.nextLine();
    int epoch = scanner.nextInt();
    enfold tallness = scanner.nextDouble();
    return novel SpecialSample(name, epoch, tallness);

    public static ineffectual valuable(){
    System.out.println(“1.Searchn2.Reinstate with consecrated condemnationn3.Modifyn4.Designation with Indicate OR Epoch OR Tallness n5.Exit”);
    //implore input from user
    System.out.println(“Invade your valuable: “);
    Scanner inputScanner=novel Scanner(System.in);
    int inputChoice=inputScanner.nextInt();
    int curb=inputChoice;

    //User achieve be imploreed restraint valuable until chosen restraint Departure
    while (inputChoice!=5){
    System.out.println(“1.Searchn2.Reinstate with consecrated condemnationn3.Modifyn4.Designation with Indicate OR Epoch OR Tallness n5.Exit”);
    int departureChoice=inputScanner.nextInt();
    switch (check){
    case 1 :
    System.out.println(“Pleas invade indicate to quest”);
    case 2 :
    System.out.println(“Please invade the condemnation”);
    int condemnation = inputScanner.nextInt();
    replace(index, takeUserInput());
    case 3 :
    case 4 :
    System.out.println(“Choose undivided criteria to designation unmoulded Indicate OR Epoch Tallness : “);
    String valuableOfSortingCriteria = inputScanner.nextLine();
    case 5 :

    //Order to quest
    public static ineffectual quest(String indicate){
    for(int i=0; i<personArray.length;i++){
    int epoch=0;enfold tallness=0f;
    if(personArray[i].equals(novel SpecialSample(name,age, tallness))){
    System.out.println(“Build : ” + specialArray[i].toString());
    System.out.println(“Not Build”);

    //Order to reinstate
    public static ineffectual reinstate(int condemnation, SpecialSample specialObject){
    if(condemnation > specialArray.length){
    System.out.println(“Please invade substantial condemnation”);
    personArray[index] = specialObject;

    //Order to variegate
    public static ineffectual variegate(){
    System.out.println(“Choose from the views listed to variegate:”);
    for(int i=0;i<personArray.length;i++){
    System.out.println(“Chosen condemnation [1-10]:”);
    Scanner scanner = novel Scanner(System.in);
    int condemnationSelected = scanner.nextInt();
    personArray[indexSelected] = takeUserInput();;

    //Order to designation
    public static ineffectual designation(String touchstone){
    List<PersonSample> buffList = Decks.asList(personArray);
    Collections.sort(buffList, SpecialSample.nameComparator);
    else if(criterion.equalsIgnoreCase(“age”))
    Collections.sort(buffList, SpecialSample.ageComparator);
    else if(criterion.equalsIgnoreCase(“height”))
    Collections.sort(buffList, SpecialSample.heightComparator);
    System.out.println(“Sorted list: “);
    buffList.forEach(special -> System.out.println(person.toString()));
    public static ineffectual ocean(String[] args) {
    // TODO Auto-generated order stub

    //Taking 10 user inputs
    for(int i = 0; i< 10; i++){
    personArray[i] = takeUserInput();