Escolar Documentos
Profissional Documentos
Cultura Documentos
Polymorphism
CSc 152
Binding
Consider this method call:
student.computeGrade();
CSc 152
Polymorphism
CSc 152
Polymorphism
an Occupation object, or
CSc 152
RoadBike
MountainBike
CSc 152
RoadBike
Widening
conversion
(no problem)
MountainBike
Bicycle bike3;
bike3 = new RoadBike (40, 20, 8, 23 );
Narrowing
conversion
(needs cast)
MountainBike bike2 ;
bike2 = (MountainBike) new Bicycle (20,10,1);
CSc
152
StaffMember
(Abstract class)
paying employees:
Volunteer
Employee
Executive
Hourly
10
CSc 152
11
yada yada
CSc 152
12
Sorting
CSc 152
Selection Sort
Insertion Sort
Polymorphism, Sorting and Searching
13
Selection Sort
General approach:
q
Select a value and put it in its final place into the list
14
Selection Sort
An example:
select
select smallest:
3
1
1
1
1
9
9
2
2
2
6
6
6
3
3
1
3
3
6
6
2
2
9
9
9
15
Swapping
temp = blueBucket;
blueBucket = redBucket;
redBucket = temp;
3
1
temp
CSc 152
16
CSc 152
17