Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the following base class: A friend on social media has the following features: First Name Last Name Friendship level: values can be one of

Write the following base class:

A friend on social media has the following features:

First Name

Last Name

Friendship level: values can be one of the choices best, ultra, great, good, acquaintance, the category was borrowed from PokemonGo

The friend has the following behaviors

Constructor/s: set MAX_IN_LEVEL as 2

toString: returns first, last names and friendship level as a String

improveFS: improve friendship level by one category higher

A friendGroup has the following features;

An arrayList of friends

The friendGroup has the following behaviors

Constructor/s: instantiate an ArrayList or assign value of friends to the instance variable

Display friends: use for each loop (enhanced for loop) to display all friends

findFriend(String first)

listFriends(friendship level passed as parameter): list all friends in that category

addFriend(Friend aFriend)

addFriend(int index, Friend aFriend)

removeFriend(String first)

removeAll(friendship level passed as parameter): remove all friends in that category

improvable(String first): check if the higher level of the friendship is full, if it is full, return false, if not, return true

improveFriend(String first): first check if the friendship can be improved, if it is improvable, improve the friendship

A tester class

FriendGroup homies = new FriendGroup();

homies.addFriend(new Friend("Tim", "Roberts", 4));

homies.addFriend(new Friend("Mary", "Roberts", 4));

homies.addFriend(new Friend("Tom", "Roberts", 3));

homies.addFriend(new Friend("Tam", "Roberts", 2));

homies.addFriend(3, new Friend("Terry", "Roberts", 3)); homies.addFriend(new Friend("Carrie", "Roberts", 1));

;

homies.displayFriends();

homies.listFriends(2);

sysout(homies.improveFriend(Terry);

homies.displayFriends();

sysout(homies.improveFriend(Carrie);

homies.listFriends(2);

homies.removeFriend(Mary);

homies.listFriends(4);

sysout(homies.improveFriend(Terry);

homies.removeAll(3);

homies.displayFriends();

sysout(findFriend(Tam);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Step: 3

blur-text-image

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

1. Explain the 2nd world war. 2. Who is the father of history?

Answered: 1 week ago