Create an enum OperatingSystem with values iOS/Android/WindowsMobile add final field operatingSystem in to Phone class

TASK 1

Create an enum OperatingSystem with values iOS/Android/WindowsMobile
add final field operatingSystem in to Phone class

TASK 2

Need assignment help for this question?

If you need assistance with writing your essay, we are ready to help you!

OUR PROCESS

Order

Payment

Writing

Delivery

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 🙂

TASK 3

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
https://javahungry.blogspot.com/2018/12/enum-in-java-complete-guide-with-examples.html

TASK 4

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.

TASK 5
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..

TASK 6
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

https://crunchify.com/hashmap-vs-concurrenthashmap-vs-synchronizedmap-how-a-hashmap-can-be-synchronized-in-java/

INNER CLASSES:
https://techvidvan.com/tutorials/java-inner-class/

TASK 7
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.

ANONYMOUS CLASS
https://www.geeksforgeeks.org/anonymous-inner-class-java/

TASK 8
Anonymous comparator

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:

https://web.stanford.edu/~ouster/cgi-bin/papers/threads.pdf
http://tutorials.jenkov.com/java-concurrency/index.html

TASK 9 A

RUNNABLE
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.

https://www.baeldung.com/java-runnable-callable
https://howtodoinjava.com/java/multi-threading/java-callable-future-example/

TASK 10
CALLABLE
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

TASK 11
LAMBDA
https://medium.com/swlh/functionally-anonymous-lambda-expression-in-java-62a9f616b753
Change the anonymous comparator created in task 8 into lambda.

https://www.w3schools.com/java/java_lambda.asp

ANNOTATION
https://www.baeldung.com/java-override – basic @overrides info

https://www.baeldung.com/java-custom-annotation
https://github.com/eugenp/tutorials/tree/master/core-java-modules/core-java-annotations

https://www.baeldung.com/java-reflection – basic reflections

TASK 12
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;

TASK 13
Add custom field annotation @Mapped. Now ObjectToSql should only save fields with annotation @Mapped.

TASK 14
Add custom class annotation @MappedClass. Now ObjectToSql should only prepare sql if the class has that annotation.

 

generic types

Task 15
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

TASK 16
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.

TASK 17
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

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply