// Title	: Abdulla							
// Programmer	: Abdulla AL-mutawa					        
// Date Written	: 11/01/00					
// Purpose	: this is the second class for this assignment it have 
//              : constructor and some methods  to accept a string input
//              : entered in class Interface then it will return a string 
//              : in ascending order and in descending order (reverse order) 
//              : to the main class (Interface)



// Imported libraries

  import java.awt.*;
  import java.applet.Applet;
  import java.awt.event.*;
               

// Main class 
 public class Sort
      
   {
             
      	String five = " ";
      	int[] sort  = new int[20];
      	int lost, count, number, abdulla;   
     
          
public Sort()  //constructor
   {
      	count = 0; 
      	lost  = 0;
   }
// end Sort
         
public void getNumber(int number)  
    {
      	sort[count] = number;
      	count++;
	         
}
// end method getNumber
             
public String getascending()		//method for ascending order
    {
       	int index;
       	five = ""; 

      	for(index=0; index<count; index++)
        five = five + sort[index] + ",";
         return five;
}
// end method getascending

public String getdescending()  		//method for descending order
   {
      	int index;
      	five = ""; 
        
      	for(index=count - 1; index>=0; index--)
      	five = five + sort[index] + ",";
      	return five;
                
}
// end method getdescending
public void sorted()
   {
                   
      	int pass;
      	for(pass =0; pass<count-1; pass++)
      	for(abdulla = pass+1;abdulla < count; abdulla++)
      	if (sort[pass] < sort[abdulla])
	
{
     	lost = sort[pass];
     	sort[pass] = sort[abdulla];
     	sort[abdulla] = lost;
}
	             
}// end method Sorted

public void clear()
   {
       	count = 0;
       	for(abdulla=0; abdulla<sort.length; abdulla++)
       	sort[abdulla] = 0;
}
// end method clear
                  
}  
//end class Sort
