/* "Copyright (c) 2012 by Fritz Sieker."
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written
* agreement is hereby granted, provided that the above copyright notice
* and the following two paragraphs appear in all copies of this software.
*
* IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR
* HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
* BASIS, AND THE AUTHOR NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
* UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*/
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.NoSuchElementException;
import java.io.FileNotFoundException;
/** This class provides code for testing the classes MyXXX.java
* that you will complete. Do NOT change anything or add anything
* to this class
*/
public abstract class AssignX extends Shell
{
/** Determine if the denominator evenly divides the numerator. If a = b/c
* (in integers) and c divides b evenly, then ac = b.
* @param numerator - any integer
* @param denominator any integer
* @return true
if denominator
evenly divides
* numerator
. Otherwise, return false
.
*/
public abstract boolean divides (int numerator, int denominator);
/** Find all elements of the list that are evenly divisible by the denominator
* @param list - an array of integer values
* @param denominator any integer
* @return a list (possibly empty) containing only those elements
* that are evenly divisible by the denominator
. The values
* in the returned list must be in the same order as the values occur
* in the parameter list
.
*/
public abstract int[] findMultiples (int[] list, int denominator);
/** Count the number of words and the number of lines in a file.
* If the file does not exist, print 0 for both values. The output should be
* the number of lines followed by a blank followed by the number of words
* followed by a newline. For this assignment, a word is any group of
* characters. Thus 3.14. is a word. To check you answer, you may use the
* wc
command from a terminal shell.
* @param fileName - the name of the file to process.
*/
public abstract void wordCount (String fileName);
/** Merge two sorted lists to produce a sorted list containing all the values
* from both lists. Duplicates are allowed. You must handle
* all possible values for the lists, including empty/null lists.
* You many not use any java
sort methods. If either of the
* lists is null
, return the other list as the answer.
* @param list1 - an array of sorted values
* @param list2 - another array of values
* @return a sorted list containing the elements from both lists.
*/
public abstract int[] merge (int[] list1, int[] list2);
/** Given a list of names, print out all combinations of the names taken
* three at a time. If the list has too few elements, don't print anything.
* Names must occur in the same order that they
* appear in the list. So, if the list contains the names Kennedy,
* Johnson, Nixon, Ford
, you program prints:
*
* [Kennedy, Johnson, Nixon] * [Kennedy, Johnson, Ford] * [Kennedy, Nixon, Ford] * [Johnson, Nixon, Ford] **
Put the values in an array
and then use the
* Arrays.toString()
method to print the results, one per line.
* @param list - a list of name.
*/
public abstract void trio (String[] list);
/** Display a list of commands useful for testing the classes you will
* complete for this assignment.
* The commands are:
*