9 1 ' "

, '

 

1.

MyCar . :

 

 

public class MyCar {

public static final int LAMBORGHINI = 2;

public static final int SUSITA = 4;

public static final int RENAULT = 5;

private int type;

 

public MyCar(int type) {

this.type = type;

}

public String getManufacturerName(){

switch (type) {

case LAMBORGHINI:

return "LAMBORGHINI";

case RENAULT:

return "RENAULT";

case SUSITA:

return "SUSITA";

}

return "Manufacturer Unknown";

}

public int getNumOfDoors(){

switch (type) {

case LAMBORGHINI:

return LAMBORGHINI;

case RENAULT:

return RENAULT;

case SUSITA:

return SUSITA;

}

return -1;

}

}

 

:

 

public class MyCarDemo {

 

public static void main(String[] args) {

MyCar bimba = new MyCar(MyCar.LAMBORGHINI);

 

System.out.println("bimba was manufactured by " +

bimba.getManufacturerName());

 

System.out.println("bimba has " + bimba.getNumOfDoors() +

" door" + (bimba.getNumOfDoors() == 1 ? "" : "s"));

}

}

MyCar:

.       

1)       . . ?

 

2)       . .

 

                                                               i.     

                                                             ii.     

.       

1)       . . ?

 

2)       " ( ) . .

 

.        " enum.

.      (10 ) ( , , ') ( 5 -4 )? .

 


2.

 

!!

 

SortedSet . , - .

 

, SimpleSortedSet. .

 

-Sets , " . / . ( ', ', ) .

 

SortedIterator, Iterator .

 

. CompositeSortedSet . .

 

( , ). . :

        size()

        isEmpty()

        getMinimum()

        getMaximum()

 

. MergedSortedSet SortedSet A -SortedSet B A -B (" ). :

       

        contains()

        iterator()

 

:

/**

 * Returns an Iterator for the elements of this set.

*/

public SortedIterator iterator() {

          return new MergedSortedIterator(setA.iterator(), setB.iterator());

}

MergedSortedIterator SortedIterator

 

. DifferenceSortedSet SortedSet A -SortedSet B -A -B. ( ) -CompositeSortedSet.

 

. UnifiedSortedSet -A -B. .