Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

((((((((((Please include comments and javadoc comments!! ))))))))) import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; public class DirectorySortDemo { public static void main(String[] args) { String[] dirNames

((((((((((Please include comments and javadoc comments!! )))))))))

image text in transcribed

import java.util.ArrayList; import java.util.Arrays; import java.util.Collections;

public class DirectorySortDemo { public static void main(String[] args) { String[] dirNames = {"dir12", "dir5", "dir9", "dir1", "dir4", "lab10", "lab2", "lab7", "lab17", "lab8", "quiz8", "quiz10", "quiz11", "quiz12", "dir11", "dir8", "dir7", "dir15", "dir3"}; ArrayList directories = new ArrayList(Arrays.asList(dirNames)); System.out.println("Unsorted List:"); System.out.println(directories); Collections.sort(directories, new DirectoryComparator()); System.out.println(); System.out.println("Sorted List:"); System.out.println(directories); } }

Assignment 6 It is common for people to name directories as dir1, dir2, and so on. When there are ten or more directories, the operating system displays them in dictionary order, as dir1, dir10, dir11, dir12, dir2, dir3, and so on. That is irritating, and it is easy to fix. Provide a comparator that compares strings that end in digit sequences in a way that makes sense to a human. First compare the part before the digit as strings, and then compare the numeric values of the digits. Your program should work with the provided test program Call the class you write DirectoryComparator.java. Submit the provided test class and your comparator in your submission. Follow all directions in the COP3337 Class Rules for Submitting Programs. Please use the file> export>to zip option in NetBeans. The zip file should be named FirstNameLastNameA6.zip

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

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

Students also viewed these Databases questions