Create an enum OperatingSystem with values iOS/Android/WindowsMobile
add final field operatingSystem in to Phone class
Need assignment help for this question?
If you need assistance with writing your essay, we are ready to help you!
Why Choose Us: Cost-efficiency, Plagiarism free, Money Back Guarantee, On-time Delivery, Total Сonfidentiality, 24/7 Support, 100% originality
1. Create an enum FoodType inside Animal class with values meet/crops/all
add final field foodType to Animal class choose it basing on a species.
2. Add switch case to feed method:
– in case of omnivores 50% mass of food will be built into body mass
– in case of carnivorous 70% mass of food will be built into body mass
– in case of herbivorous 30% mass of food will be built into body mass
3. add field foodToBodyRatio to enum FoodType
4. redo feed method
5. change method feed to get foodType as a parameter, if it doesn’t fit to animal there should be a text information and no body mass gain
6. will it be better now to move FoodType outside the Animal class? so move it out 🙂
Create an enum Country with values of few country names and fields String language and String code as country code from https://pl.wikipedia.org/wiki/ISO_3166-1
Add field GDP counted in USD
Add method that returns GDP of country in PLN
Create a HashMap with Country as key and Double area as value.
Add 5 countries to the map.
Find the smallest and the largest country in your map.
Create a HashMap with String name of capital city as key and Country as value
Add a few countries into a map.
Print all countries, sort it by capital city alphabetically..
Create a HashMap with FoodType as a key and List of Animals as value. Add to the lists Pets, FarmAnimals, Humans.
Example with HashMap for performance.
Example with SynhronizedHashMap
Create a private inner class engine inside a car.
Move turnOn() method to the new class.
Add fields horsePower and volume and milage.
Add Engine engine field to a car and create an engine in the car constructor.
Add isRunning boolean field to a car.
Add startACar() method to a car which will run turnOn() method on engine.
TurnOn() method should print some funny text and change isRunnig value.
Add stopACar() method as analogy.
Create a List of Animals
Add 6 Animals/Humans/Pets/FarmAnimals to it
Sort it by weight using anonymous comparator
EXAMPLE WITH MAILING LIST
additional multithreading theory:
TASK 9 A
Create a new class that implements Runnable in the new package called treads
In run() method count seconds from 10 to 0
Run it in 2 threads in the same time
TASK 9 B
Create two classes that extend your runnable one called SubZero one called Scorpion.
Every of them should have a method finishHim() with a different description of fatality.
add finishHim() on the end of your run() method.
Run both of them at the same time a few times.
Who attacks first and wins?
TASK 9 C
Delete classes SubZero and Scorpion
Create a new interface called Finisher with one method finishHim() // mortal kombat?
Add a new field type Finisher to your runnable class
add finisher.finishHim() on the end of your run method
Implement two different bodies for two finishers as an anonymous method in main. One for Sub Zero and one for Scorpion.
Run both runnable at the same time.
TASK 9 D
Change anonymous implementations into lambda.
How it works?
TASK 9 E
Create a class that implements Callable and returns a random double value on the end of call() method.
In call method count seconds from 3 to 0 and then return random double from 0 to 1
Assign this value to a Future object.
Check how many other lines of code you can run and when program will wait to your result
Write numbers to a console.
TASK 9 F
Add finishers to your callable.
Create a few different finishers.
Store random numbers to decide who wins.
Fire the finisher fatality of the winner.
Create a CallableSorter with List of numbers as a parameter and as returned object
BubbleSort lists in call() method
create 4 different sized lists with random numbers
sort them one by one and measure time
sort them in the same time and measure time
Catch sorted lists into Future objects
Change the anonymous comparator created in task 8 into lambda.
https://www.baeldung.com/java-override – basic @overrides info
https://www.baeldung.com/java-reflection – basic reflections
Create an ObjectToSql class with method insert(Object object) that will prepare an sql code which inserts every field in the object. Table name should be the same as class name;
Add custom field annotation @Mapped. Now ObjectToSql should only save fields with annotation @Mapped.
Add custom class annotation @MappedClass. Now ObjectToSql should only prepare sql if the class has that annotation.
Create a class SuperNumber that has one field of any type. Add methods which print the class name of that type. Bound types to extends Numerics and create methods that:
return double value
return int value
check if double value == int value
check if int value of other SuperNumber object is the same
check if double value of other SuperNumber object is the same
Create a generic class Container that implements Collection interface. That class should store a list of objects of a generic type and the number of changes performed on that list. Every time you change the list that number has to increase.
Extend a Container class to ContainerWithMemory. That class should store every version of your list. There should be methods that will allow you to restore a specific version, print specific version, print all the history