// Scaffold for Junior Knights Sorting Assignment
// Please save as sort.java and then add code to the three methods
// bubbleSort(), insertionSort() and selectionSort().

import java.util.*;

public class sort {

	private int[] array;
	private static Random r = new Random();

	// Creates a sort object with len elements each in between 1 and max, inclusive.
	// Initial object is unsorted.
	public sort(int len, int max) {

		// Allocate space for the array.
		array = new int[len];

		// Fill each array slot with a random number from 1 to max.
		for (int i=0; i<array.length; i++)
			array[i] = r.nextInt(max) + 1;
	}
	
	// Returns true iff this sort object is sorted.
	public boolean isSorted() {
		for (int i=0; i<array.length-1; i++)
			if (array[i] > array[i+1])
				return false;
		return true;
	}

	// Returns a string representation of this object, each item followed by a space.
	public String toString() {
		String res = "";
		for (int i=0; i<array.length; i++)
			res = res + (array[i]+" ");
		return res;
	}

	// Sorts this sort object via the Bubble Sort Algorithm.
	public void bubbleSort() {


	}

	// Sorts this object via the Insertion Sort Algorithm.
	public void insertionSort() {


	}

	// Sorts this object via the Selection Sort Algorithm.
	public void selectionSort() {


	}

	public static void main(String[] args) {
	
		// Basic tests - you can avoid printing when testing larger arrays.

		// Test bubble.
		sort test1 = new sort(20, 100);
		System.out.println(test1);
		test1.bubbleSort();
		if (!test1.isSorted())
			System.out.println("Test failed!");
		System.out.println(test1);
		System.out.println();
		
		// Test insertion.
		sort test2 = new sort(20, 100);
		System.out.println(test2);
		test2.insertionSort();
		if (!test2.isSorted())
			System.out.println("Test failed!");
		System.out.println(test2);		
		System.out.println();
		
		// Test selection.
		sort test3 = new sort(20, 100);
		System.out.println(test3);
		test3.selectionSort();
		if (!test3.isSorted())
			System.out.println("Test failed!");
		System.out.println(test3);

		/*** Various other tests.
		 
		sort small = new sort(10, 100);
		small.print();
		sort medium = new sort(25, 1000);
		medium.print();
		sort large = new sort(100, 1000000);
		large.print();
		System.out.println();

		small.bubbleSort();
		small.print();
		medium.print();
		System.out.println();

		medium.insertionSort();
		large.selectionSort();
		medium.print();
		large.print();

		for (int len=1000; len<=80000; len=len+1000) {

			long start = System.currentTimeMillis();
			sort test = new sort(len, 1000000);
			test.bubbleSort();
			long end = System.currentTimeMillis();
			System.out.println("size = "+len+" time = "+(end-start)+" ms.");
		}

		***/
	}
}