Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Class Pet that... has the following attributes - String name - Integer age - String type Class Person that... has the following attributes - String

Class Pet that...

has the following attributes

- String name

- Integer age

- String type

Class Person that...

has the following attributes

- String name

- Integer age

- List pets

Class Business that...

has the following attributes

- String name

- String Address

- Person owner

- String postalCode

- List customers

All class members should be private, classes should include getters / constructors using lombok

Q1 Function that takes in a List and a String name, and returns a List of all the customers that have visited a business with the name (where business.name equals String name)

-- solved using streams

Q2 Function that takes in a List and returns a List of all the people that are owners that are customers of their own business (where business.customers contains business.owner)

-- solved using streams

Q3 Function that takes in a List and returns a List that is a *distinct* list of every pet of all the customers

-- solved using streams

Q4 Function that takes in a List and returns a Map where the key is the owner and the value is the business the owner owns (you may assume the owners in the list only own a single business)

-- solved using streams

Q5 Function that takes in a List and a Map (key == business.name, value == revenue) and returns a Map (key = owner, value = revenue) (you may assume the owners in the list only own a single business)

-- solved using streams

Q6 function that takes in an Integer n and Recursively turns the number into its string representation as you would say the number, e.x 878444 => "eight hundred seventy eight thousand four hundred forty four"

*you can assume that n will always be less than one million (n<=999,999) and positive *-2 points if this is not solved with recursion

Q7 recursive function called multiply takes in an integer a and an integer b, and returns the product of (a, b) using only addition (you can assume a,b are always positive)

-2 points if this is not solved with recursion

Q8 unit test for Q1->3 + Q7

Q1 sample input

[ {name : walmart,

address: some lane,

owner: joe

postalCode: n9n0a5

customers: [{name: joe, age : 22, pets: []},{ name: jill, age 25, pets :[{name : goldie, age: 3, type : fish}]}] },

{name : freshie,

address: some other lane,

owner: joe postalCode: n9n0a5

customers: [{name: jill, age 25, pets :[{name : goldie, age: 3, type : fish}]}]

}

]

name = walmart

sample output

[{name: joe, age : 22, pets: []},{ name: jill, age 25, pets :[{name : goldie, age: 3, type : fish}]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Classes Java Pet class with Lombok annotations for gettersconstructors Getter AllArgsConstructor public class Pet private String name private Integer ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions

Question

Summarize the key challenges faced in training expatriate managers.

Answered: 1 week ago