/* * File UseList.java * * This is the main class we use to test our * classes List and OrdList. * */ public class UseList { /* This method is going to be the first one called at runtime. */ public static void main(String argc[]) { /* This is the array used to create the list. */ int[] MyArray = {11, 3, 6, 5, 9}; /* We create two objects : * -> MyList : type 'List'. It is an instance of the class 'List'. * -> MyOrdList : type 'OrdList'. It is an instance of the class 'OrdList'. */ List MyList = new List(MyArray); OrdList MyOrdList = new OrdList(MyArray); MyList.insert(5, 7); // Inserts the number 7 in fifth position. /* The method insert() from the class 'List' is called here. */ MyOrdList.insert(7); // Inserts the number 7 in the sorted list. /* The method insert() from the class 'OrdList' is called. */ /* In both case we called the method print() of the class 'List'.*/ System.out.print("List : "); MyList.print(); System.out.print("Sorted list : "); MyOrdList.print(); } }