Computer Science 210
Data Structures

Fall 2017, Siena College

Programming Project 3: Sorting with Comparators
Due: 11:59 PM, Friday, October 27, 2017

This programming project focuses on sorting. You will learn the power of Java's Comparator interface as it applies to writing a generalized sorting method. You will extend the functionality of an existing class using inheritance, you will implement a simple sorting procedure within this extension, and you will learn about Comparators, which provide a more flexible mechanism for ordering objects than the Comparables we have seen in class.

You may work alone or in a group of two or three on this project. Of course, collaboration with your partner(s) is unrestricted. You may discuss the assignment with your classmates and give and receive some help, but your submission must be your own work (or that of you and your teammates, if you choose to form a group).

Getting Set Up

You will receive an email with the link to follow to set up your GitHub repository sorting-project-yourgitname for this Programming Project. One member of the group should follow the link to set up the repository on GitHub, then that person should email the instructor with the other group members' GitHub usernames so they can be granted access. This will allow all members of the group to clone the repository and commit and push changes to the origin on GitHub. At least one group member should make a clone of the repository to begin work.

Please answer lab questions in the README.md file in your group's GitHub repository.

Command-line Parameters

We can provide information to a Java application through the args parameter to its main method. As you can see from the main method signature we have been using all semester, it is an array of Strings. These String values come from what the program's user types after its name on the command line when running the program. Different Java IDEs provide different mechanisms for specifying these Strings, known as command-line parameters. In BlueJ, these are specified in a dialog box that we have been ignoring each time we run a Java application - the one that comes up after you choose main from the right-click menu to run your application. To specify the command-line parameters, we specify them as an array of String with the same syntax as a statically initialized array in Java. For example, we could specify an array of 3 String values:

  { "Java", "is", "fun" }

The Java run-time system will construct and initialize an array with these values, and we can access "Java" as args[0], "is" as args[1], and "fun" as args[2] in our program's main method.

Practice Program: Write a Java application in a program ArgAdder.java that takes any number of integers as command-line parameters (though they will come to you as String values) and prints their sum. (6 points)

Note: you can convert a String whose contents can be interpreted as an integer value to an int by passing it to the Integer.parseInt method.

Programming Assignment

We will do the laboratory at the end of Chapter 6 in Bailey. You will need to read about the Comparator interface in Section 6.8.

Please note the following clarifications, modifications, and explanations relating to the lab procedure outlined in the text:

Question 1: Answer Thought Question 1 on p. 147-148 of Bailey. (3 points)

Question 2: Answer Thought Question 2 on p. 148 of Bailey. (3 points)

Submitting

Your submission requires that all required deliverables are committed and pushed to the master for your repository's origin on GitHub. That's it! If you see everything you intend to submit when you visit your repository's page on GitHub, you're set.

Grading

This assignment is worth 60 points, which are distributed as follows:

> FeatureValueScore
ArgAdder.java correctness 6
MyVector correctness 15
MyVector test in main method 5
Comparators correctness 10
MyVector and Comparators design and style 6
MyVector and Comparators documentation 7
Sorting applications 5
Bailey Thought Question 1 3
Bailey Thought Question 2 3
Total 60