适配器模式

作者:可乐fan  发布时间:2014-05-15 23:52:17

适配器

姓名:何桥   学号:201130690105

UML设计图

一、类适配器

 

二、对象适配器

 

核心实现代码

一、适配器接口

   interface SortInfo//接口声明所有需要的方法

    {

       int[] sort(int[] s);

    }

二、快速排序类的实现

    class QuickSort//实现快速排序类

    {

        public QuickSort()//无参构造{ }

        public int[] quickSort(int[] s)

        {  return quickSort(s,0,s.Length-1);//递归调用}

        int[] quickSort(int[] s, int low, int high)

        {   if (low < high)

            {   int key = s[low];

                int left = low;

                int right = high;

                while (left < right)

                {

                    while (left < right && s[right] >= key)

                    {   right--; }

                    s[left] = s[right];

             &nb