Lab05
5th lab at 14.10.2024
Comparable / Comparator interfaces
Work with Comparable and Comparator
Use project at https://gitlab.vsb.cz/jez04-vyuka/java-efrei/efrei-lab04.git as a base to complete the following tasks.
- Crate or use collection of fighters and shuffle them before fighting.
- Try to sort collection fithout any change of code.
- Ensure that Fighter implements interface Comparable to compare fighters baso on name.
- Try to sort collection again.
- Mesure time of searching an object in unsorted collection a using binarySearch in sorted collection.
- Use interface Comparator to compare Fighters base on strenght.
- Find the most strongest and the most weekest Fighter in unsorted collection.
- Create comparator which compare Fighters base on name and if name are same compare them base on strenght.
- Use static methods in class comparator to create comparator which handle null values
- Use static methods in class comparator to create comparator which use keyExtractor to compare fighters base on remaining lives.
- Try to compare collection of strings witch contains language specific character like ('č', 'ř', 'Ž'). Try to use class Collator. Get the instance using method Collator.getInstance
- Try to create comparator which compare string with numbers (like street name with number in post address). String format could be "street_name 1234". Comparator compare first part of string and if it same compare second part as number so "street 19" will be greater then "street 8".
Solution
solution can be found in project original project in branche solution