Question: ( CSCI 2 5 1 ) Project Two Implement and Apply Stack and Queue Purpose: The purpose for this project is to reinforce the knowledge

(CSCI 251) Project Two Implement and Apply Stack and Queue Purpose:
The purpose for this project is to reinforce the knowledge from Chapter Two of the textbook. The students will practice how to implement stack and queue data structure using list structure, for instance, ArrayList. The students will also apply stack and queue in real project, for instance, to check if a string is a palindrom.
Tasks: 1. Use ArrayList to implement MyStack class which define the data structure that has Last In First Out property (35%)
2. Use ArrayList to implement MyQueue class which define the data structure that has First In First Out property (35%)
3. Write a function public static Boolean isPalindrome(String sentence)(30%).
This function returns true if sentence is a palindrome; false otherwise.
Sample files: Three sample files are given. The students should add necessary comments to all files and implement all functionalities in the given files.
No extra functions can be added. No function name can be changed. The students should run the executable jar file to see how project should run.
The students should zip whole project and submit it via blackboard link.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//
// CSCI251ProjTwo.cpp
// ProjectTwoCSCI251
#include
#include
#include
#include "MyStack.h"
#include "MyQueue.h"
using namespace std;
bool isPalindrome(string sentence);
int main(){
string sentence;
char choice;
do{
cout <<"Enter a sentence: ";
getline(cin, sentence);
cout <<"\""<< sentence <<"\"";
if(isPalindrome(sentence))
cout <<" is a palindrome" << endl;
else
cout <<" is NOT a palindrome" << endl;
cout <<"Do you want to make another check? Y/N :";
cin >> choice; // get input char
cin.ignore(); // ignore new lines
}while(choice =='y'|| choice =='Y');
cout << "Thanks for choose the ";
return 0;
}
bool isPalindrome(string sentence){
// you implement this
}
---------------------------------------------------------------------------------------------------------------------------
//
// MyQueue.hpp
#ifndef MyQueue_h
#define MyQueue_h
#include
#include
using namespace std;
template
class MyQueue{
public:
MyQueue();
T pop();
void push(T item);
T peek() const;
int size() const;
bool isEmpty() const;
private:
list q; // we use a list to hold data for queue
};
#include "MyQueue.cpp"
#endif /* MyQueue_hpp */
----------------------------------------------------------------------------------------------------------------
//
// MyStack.h
#ifndef MyStack_h
#define MyStack_h
#include
#include
using namespace std;
template
class MyStack{
public:
MyStack();
void push(T item);
T pop();
T peek() const; // const means that the function will not change the content of the object
int size() const;
bool isEmpty() const;
private:
vector v; // use a vector to hold data in stack
};
#include "MyStack.cpp"
#endif /* MyStack_hpp */

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!