Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify your HW1 in a way that your followers should be stored in an Array object (a dynamic array created by Array class). That means

Modify your HW1 in a way that your followers should be stored in an Array object (a dynamic array created by Array class). That means you should use the Array class we discussed in the class.

USE THIS ARRAY TEMPLATE:

image text in transcribed

a. Do your initializations with the constructor. I recommend you to start with an Array object of size 2. 2.

Instead of working with a fixed size array, your program should change the size of the array when it is full or only a small portion of the current capacity is used. Therefore, you should use changeSize() function inside addFollower() and removeFollower() functions.

a. You should call changeSize() to double the size when the array is full.

b. You should call changeSize() to cut the array into half if less than 25% of the array is being utilized.

This is the code for hw#1. It is missing a constructor that does initialization for the followed user and number of followers, so please add one before starting:

#include #include "Twitter.h"

using namespace std;

struct Profile { string username; int age; string state; bool operator==(const Profile& p) const {//added this so that the operators in RemoveFollower function work return username == p.username && age == p.age && state == p.state; } };

// Overload the

int main() { Twitter twitterStr; Twitter twitterProfile;

// Add followers to the string Twitter object /*twitterStr.AddFollower("User1"); twitterStr.AddFollower("User2"); twitterStr.AddFollower("User3"); twitterStr.AddFollower("User4"); twitterStr.AddFollower("User5"); twitterStr.AddFollower("User6"); This would prompt the "Follower list is full" output at the beginning, comment out for now

twitterStr.PrintFollowers(); cout

// Add followers to the profile Twitter object Profile user1 = {"person1", 20, "NY"}; Profile user2 = {"person2", 40, "CA"}; Profile user3 = {"person3", 25, "FL"}; Profile user4 = {"person4", 15, "TX"}; Profile user5 = {"person5", 4, "MI"};

twitterProfile.AddFollower(user1); twitterProfile.AddFollower(user2); twitterProfile.AddFollower(user3); twitterProfile.AddFollower(user4); twitterProfile.AddFollower(user5);

// Remove a follower from the string Twitter object // twitterStr.RemoveFollower("User1"); //THIS PRINTS OUT THE FIRST LIST, WITHOUT PROFILES

// Remove a follower from the profile Twitter object twitterProfile.PrintFollowers(); cout

SHOW Array.h, Twitter.h, and the main.cpp

thank youuuuu

1 // Array.h -- class template for an adjustable array 2 // When debugging, use \#define DEBUG_ARRAY above your \#include Array line. 3 // When done debugging, comment out \#define DEBUG_ARRAY for better performance. 4 // The constructor and the changeSize function can cause an exception to be thrown if out of // heap memory. \#include > using namespace std; template >

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_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

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions

Question

4-6 Is there a digital divide? If so, why does it matter?

Answered: 1 week ago