Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

hi guys, i need help with this program. Need\'s a stack class that... push\'s po

ID: 3801806 • Letter: H

Question

hi guys, i need help with this program.

Need's a stack class that...

push's

pop's

isEmpty

makeEmpty

peek

print.

With my stack class, i'm going to #include it in my Facebook class, which should do this...

addFriend(): add's them since they are a stack object. meaning I use the push function in the stack class

removeFriend(): remove's them with the pop function, removing them from the list.

printFriends(): this simply enables the print() function from the stack

latestFriend(): we should use the peek() fuction, printing out the latest video

resetFriends(): I believe this will do the makeEmpthy() function to empty out the friends list

checkList(): and for this we use the isEmpty() function from the stack class

These Data members can be in there too I believe
"DataTyperUser" who is going to be friended

"Stack<DataType>FriendList" this can be the friendlist in the stack form, it doesn't have to be an array

"int numOfFriends" this will track all of the friends we have

Main Program

This will #include the Facebook class, and read president's and their home states,
I have them listed like this in a text file"

etc. goes all the way down to....

All I need to know is where to put this file name in the main program, please comment where I can put that file.

With the president and homestates, the Facebook Class options should be able to this

AddFriend, should push them all into a FriendList. We want all presidents to be our friend

LatestFriend, this will print out the recent president and homestate

that sohuld come up.

All these abilities in the facebook class should work on presidents. (like ResetFriends, PrintFriends) etc, but for presidents!

i appreciate any help I can get. thank you.

Explanation / Answer

1)

I'm hoping this program is in java. Instead of creating new Stack, we can always for built-in Stack class, which supports all the operations you mentioned, and built with optimally(less complexity). That is the best way I can suggest.

Please refer the below code:

Stack<DataType>FriendList;

Example:

import java.util.Stack;

Stack<Integer> stack = new Stack<Integer>();
       stack.push(1);
       stack.pop();
       stack.isEmpty();
       stack.peek();
       stack.clear();
       stack.toString();

Instead integer you write your own data type in the above code.

2) I think you need one method to create friendList.

createFriendsList();

here you open the file, read the text from the file and add to the stack that you are going to implement.

close the file.

I hope this helps, please let me know if need any other info.