Java Language
-Create a project and a class with a main method,TestCollectors.
-Add new class, Collector, which has an int instance variablecollected, to keep track of how many of something they collected,another available, for how many of that thing exist, and a booleancompletist, which is true if we want to collect every itemavailable, or false if we don't care about having the completeset.
-Add a method addToCollection. In this method, add one tocollected and report the new value. If after this we have collectedall the available items, print a congratulatory message.
-Write a toString for this class as follows:
If there are more objects collected than are available, theresult should be something like
an overflowing collection with 20 out of 15 items
if there are exactly the same number collected as available
a perfect collection with 15 out of 15 items
if there are fewer collected than are available, it dependswhether we are being completist, so either
a sadly incomplete collection with 10 out of 15 items
or
a collection with 10 out of 15 items
[EC +10] Actually, if the number available is 0, no matter howmany are collected, the result should be
not really a collection at all
adjust your toString accordingly
In your main, create several Collectors with different valuesand check that their toStrings come out correctly
[EC+20]
-Add a new (different from part A) class with a main. In main,ask the user for a value for each of three int variables x, y, andz.
-Using conditionals and nesting/else-if, print the three intsback out in decreasing order. (You can ignore the casewhere two numbers are the same)
So whether you were given 2, 1, 3, or 1,2,3 or 3,1,2, you'dprint out 3, 2, 1.
You may add extra variables (i.e. small, med, and large) if youwish.
Make sure you test all possible orders for the threenumbers.