• Build your performance sort into your custom built collection, aka LinkedList
  • Implement a Sort into your LL in Jupyter Notebook … Here is concept.
  • Utilize Capabilities of Object overrides with toString and compareTo to Sort using Object overrides (these are built in by extending Collectable, formerly Generics).
  • Build toString to return JSON for LinkedList, Queue and/or Stack so they could be utilized with API.
  • Demostrate changing Sort keys with Tester Methods

Bubble Sort

making a custom build collection for bubble sort

  • add physical visual animation of hearts sorted ??
  • reflect the performance that we did > link video

  • add in list of computer science based pick-up lines
  • utilize Capabilities of Object overrides with toString and compareTo to Sort using Object overrides (these are built in by extending Collectable, formerly Generics).
  • give each pick-up line a different rank/numb (let the user do thi) (also sort each pickup line based on the number of characters in them)
  • Build toString to return JSON for LinkedList, Queue and/or Stack so they could be utilized with API.
  • Demostrate changing Sort keys with Tester Methods
  • add in visualization > output »>
  • sort USING BUBBLE SORT based on the assigned variables

My group did a ‘BUBBLE SORT’ presentation, we presented it as a game show. Each bachlor would say a pick-up line and Rachita would give each line a ranking. Through the ranking each of us would sort out using bubble sort.

package com.nighthawk.hacks;

import java.util.*;

class PickUpLine implements Comparable<PickUpLine> {
    private String line;
    private int rank;

    public PickUpLine(String line) {
        this.line = line;
        this.rank = 0; // Initialize rank to 0, user will input the rank later
    }

    public String getLine() {
        return line;
    }

    public int getRank() {
        return rank;
    }

    public void setRank(int rank) {
        this.rank = rank;
    }

    @Override
    public String toString() {
        return "{\"line\": \"" + line + "\", \"rank\": " + rank + "}";
    }

    @Override
    public int compareTo(PickUpLine other) {
        return Integer.compare(this.rank, other.rank);
    }

    public static Comparator<PickUpLine> LengthThenRankComparator = new Comparator<PickUpLine>() {
        @Override
        public int compare(PickUpLine line1, PickUpLine line2) {
            int lengthComparison = Integer.compare(line1.getLine().length(), line2.getLine().length());
            if (lengthComparison != 0) {
                return lengthComparison; // If lengths are different, return the comparison result
            } else {
                return Integer.compare(line1.getRank(), line2.getRank()); // If lengths are the same, compare ranks
            }
        }
    };
}

public class PickUpLineSorter {
    public static void main(String[] args) {
        // List of pick-up lines
        List<PickUpLine> pickUpLines = new ArrayList<>();
        Scanner scanner = new Scanner(System.in);

        // Add pick-up lines
        pickUpLines.add(new PickUpLine("Are you made of copper and tellurium? Because you're Cu-Te."));
        pickUpLines.add(new PickUpLine("Are you a computer keyboard? Because you're just my type."));
        pickUpLines.add(new PickUpLine("Are you a 90-degree angle? Because you're looking right."));
        pickUpLines.add(new PickUpLine("Are you a software update? Because not now."));
        pickUpLines.add(new PickUpLine("Are you Wi-Fi? Because I'm feeling a connection."));

        // Allow user to rank the pick-up lines
        System.out.println("Please rank the following pick-up lines from 1 to 10 (1 being the best and 10 being the worst):");
        List<Integer> usedRanks = new ArrayList<>();
        for (PickUpLine line : pickUpLines) {
            System.out.println(line.getLine());
            int rank = getValidRank(scanner, usedRanks);
            line.setRank(rank);
            usedRanks.add(rank);
        }

        // Sorting pick-up lines based on character length and then rank
        List<PickUpLine> sortedByLength = new ArrayList<>(pickUpLines);
        Collections.sort(sortedByLength, Comparator.comparingInt(line -> line.getLine().length()));

        List<PickUpLine> sortedByRank = new ArrayList<>(pickUpLines);
        Collections.sort(sortedByRank);

        // Printing sorted pick-up lines by character length
        System.out.println("\nSorted pick-up lines by character length:");
        for (PickUpLine line : sortedByLength) {
            System.out.println(line);
        }

        // Printing sorted pick-up lines by rank
        System.out.println("\nSorted pick-up lines by rank:");
        for (PickUpLine line : sortedByRank) {
            System.out.println(line);
        }
    }

    // Helper method to get a valid rank input from the user
    private static int getValidRank(Scanner scanner, List<Integer> usedRanks) {
        while (true) {
            System.out.print("Enter rank (1-10): ");
            int rank = scanner.nextInt();
            scanner.nextLine(); // Consume newline character
            if (rank < 1 || rank > 10) {
                System.out.println("Invalid rank. Please enter a rank between 1 and 10.");
            } else if (usedRanks.contains(rank)) {
                System.out.println("Rank already used. Please enter a different rank.");
            } else {
                return rank;
            }
        }
    }
}
|   package com.nighthawk.hacks;

illegal start of expression