Using inheritance, write a basic social network. Your network will resemble
some elements of Facebook. There should be an Account super
class. Two types will extend Account, Person and
Page. There should be a Relationship super class.
Two types will extend Relationship, Friend and
Follow. You should also have a client program for the social
network that defines the main.
Name the files Account.java, Person.java,
Page.java, Relationship.java,
Friend.java, Follow.java, and
SocialNetwork.java.
Other details:
Account - at a minimum
toString function appropriately.Person - at a minimum
Friend (note, that
Java arrays can store null).Follow.Friend or an
array of FollowaddFriend(Person p) will create a
Friend relationship between two people. Essentially it will
call a helper function of this and p that
searches for an empty (null) location in the friend array to insert a
new Friend object. If no such location exists, report
failure.like(Page p) will search the following array
for an empty location to insert a new Follow object. This
function should also increment the number of followers (through a
function) of p. If no location exists, report failure.toString function appropriately. This
function should call Account's toString
function to increase code reuse (through super). Ensure
that you output a list of friends and a list of follows
(one line per friend/follow).Page - at a minimum
int for the number of followers.toString function appropriately. This
function should call Account's toString
function to increase code reuse. Ensure that you output the number of
followers.Relationship - at a minimum
Date for the creation of the relationship
(lookup java.util.Date).toString function appropriately.Friend - at a minimum
Person (recall a
reference is a pointer). this means the Friend object
points to an existing Person object. Do not use
new when sending a Person in the
constructor.toString function appropriately. this
function should call Relationship's toString
function to increase code reuse. Only output the name of the
Person instead of calling toString.Follow - at a minimum
Page. This means the
Follow object points to an existing Page
object. Do not use new when sending a Page in
the constructor. Also increment the number of follows on that page here.
toString function appropriately. this
function should call Relationship's toString
function to increase code reuse. Only output the name of the
Page instead of calling toString.SocialNetwork - at a minimum
Person objects and one
Page object. Have both people befriend each other and also
follow the page.
Example output of SocialNetwork's test:
Person
Account name: Jory Denny
Number of friends: 1
Number of follows: 1
Friends
Friend. Relationship created Mon Nov 14 10:15:13 EST 2016. With Zachary Pollock.
Follows
Follow. Relationship created Mon Nov 14 10:15:13 EST 2016. Following Zen-Do-Kai Karate.
Person
Account name: Zachary Pollock
Number of friends: 1
Number of follows: 1
Friends
Friend. Relationship created Mon Nov 14 10:15:13 EST 2016. With Jory Denny.
Follows
Follow. Relationship created Mon Nov 14 10:15:13 EST 2016. Following Zen-Do-Kai Karate.
Page
Account name: Zen-Do-Kai Karate
Number of followers: 2
Bonus. Provide an example of polymorphism in your
product, either with relationships or accounts. Other extensions: provide a feed
and post mechanism for accounts using Strings.