Question: Please solve All parts to this problem. Java. 3. (16 points) Streams, Lambda Expressions, and Comparator-Given the following Pet class, complete wise specified. public class

Please solve All parts to this problem. Java.  Please solve All parts to this problem. Java. 3. (16 points)
Streams, Lambda Expressions, and Comparator-Given the following Pet class, complete wise specified.

3. (16 points) Streams, Lambda Expressions, and Comparator-Given the following Pet class, complete wise specified. public class Pet private String name; private int age private String breed private double weight public Pet (String name, int age, String breed, double weight) this.name name; this.age = age; this.breed breed; this.weight weight; public String name () return name;) public int age () return age; public String breed) return breed; h public double weight) return weight; A. (5 points) Complete the following method. Given a list of Pets, use streams to return the age of the oldest eresion nd e Pet of all the pets matching the given breed. For full credit, you must use one lambda key extractor pub lic int oldestByBreed (List pets, string breed) e a BiPredicate (see attached javadocs) that takes two Pet objects and returns true if the pets are the same age, and false otherwise. You must use a lambda expression in your answer. BiPredica te C. (3 points) Use your BiPredicale from Part B to complete the code below that makes a new list of all the Pet objects in the given list that are the same age as fluffy. You do not need to redeclare the BiPredicate. You must use streams in your answer. List pets = new List(); // code not shown to fill the list with pets Pet fluffy new Pet ("Fluffy", 2, "Poodle", 12.2); List sameAgeAs fluffy pets. fipr collet lcofetst La) steer4 = Not anplicable to dagane hy D. (5 points) Your kid sister thinks puppies, kittens, and small things in general are cute. Create a Comparator that orders Pets 2 years old and younger first. Pets over 2 years old should come last. In those sub catego- ries, Pets should further be ordered in ascending order by weight. (Note: It is okay if your solution creates more than one Comparator. Name the Comparator that accomplishes the complete task: tinyComp)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!