Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[C++] The program works but not in the way I want it to. I am trying to get my program output to look like the

[C++] The program works but not in the way I want it to. I am trying to get my program output to look like the picture I posted. In my program, the menu keeps repeating 3x and I don't know how I can add family member separately while at the same time, give them toDo tasks later on...

image text in transcribed

[Queue.cpp]

#ifndef QUEUE_H_INCLUDED #define QUEUE_H_INCLUDED

using namespace std;

class Queue{

private: struct Node { char *name; Node* next; }; public: Node *front, *rear; Queue(); ~Queue(); void enqueue(char*); void dequeue(char*); void display(); char name[10]; char menu(); };

#endif // QUEUE_H_INCLUDED

[Queue.cpp]

#include "Queue.h" #include "Item.h" #include #include

using namespace std;

Queue::Queue(){ front = NULL; rear = NULL; }

Queue::~Queue(){ while(front!=NULL){ Node *temp=front; front=front->next; delete temp; } rear = NULL; }

void Queue::enqueue(char *n){ Node* temp= new Node; if (temp == NULL){ cout name = n; temp->next = NULL; /* if (cin >> '3'){ Item itemA; itemA.getTask(); itemA.getDesc(); itemA.setTask(itemA.taskName); itemA.setDesc(itemA.taskDesc); itemA.addNode(itemA.taskName,itemA.taskDesc); } */ if (front== NULL){ front = rear; rear = temp; } else { rear-> next = temp; rear = temp; } cout

void Queue::dequeue(char *d){ if (front == NULL){ cout namenext; } }

void Queue::display(){ if(front ==NULL){ cout name next; Item itemB; itemB.printList(); } cout

char Queue::menu(){ char choice; cout

cin >> choice; return choice; }

[Item.h] #ifndef ITEM_H_INCLUDED #define ITEM_H_INCLUDED class Item{ private: struct node{ char taskName[10]; char taskDesc[80]; node* next; }; node* head; node* curr; node* temp; public: Item(); void addNode(char addTask[],char addDesc[]); void deleteNode(char deleteTask[],char deleteDesc[]); void printList(); void getTask(); void getDesc(); void setTask(char text[]); void setDesc(char text[]); char taskName[10]; char taskDesc[80]; }; #endif // ITEM_H_INCLUDED [Item.cpp] #include "Item.h" #include #include #include using namespace std; Item::Item(){ head = NULL; curr = NULL; temp = NULL; } void Item::addNode(char addTask[],char addDesc[]){ node* n = new node; n->next = NULL; strcpy(n->taskName,addTask); strcpy(n->taskDesc,addDesc); if (head != NULL){ curr = head; while(curr->next != NULL) { curr = curr->next; } curr->next = n; } else { head = n; } } void Item::deleteNode(char deleteTask[], char deleteDesc[]){ node* d = NULL; temp = head; curr = head; while ((curr != NULL) ){ temp = curr; curr = curr->next; } if (curr == NULL){ cout next; temp->next = curr; delete d; cout taskName taskDesc next; } } void Item::getTask()//gets the name of the task from the user { cout

[main.cpp]

#include #include "Item.h" #include "Queue.h" using namespace std;

int main() {

char choice; do { Queue A; Item B; choice = A.menu();

switch(choice){ case '1': A.enqueue(A.name); break; case '2': A.display(); break; case '3': B.addNode(B.taskName,B.taskDesc); break; case '4': B.deleteNode(B.taskName,B.taskDesc); break; default: cout

/* Item itemA; itemA.getTask(); itemA.getDesc(); itemA.setTask(itemA.taskName); itemA.setDesc(itemA.taskDesc); itemA.addNode(itemA.taskName,itemA.taskDesc); itemA.deleteNode(itemA.taskName,itemA.taskDesc); itemA.printList();

Item *itemPtr;*/ //Queue fam; //fam.menu(); //fam.enqueue(fam.name);

return 0; }

Example Program Output Welcome to the TODO list manager! Make your selection below: Press 1 add a family member. Press 2 to view all TODO lists. Press 3 to add a TODO item. Press 4 to complete a TODO item. Press 5 to exit. Choice: 2 You have not yet added any family members. Make your selection below: Press 1 add a family member. Press 2 to view all TODO lists. Press 3 to add a TODO item. Press 4 to complete a TODO item. Press 5 to exit. Choice: 1 Enter family member name: susie Family member added. Make your selection below: Press 1 add a family member. Press 2 to view all TODO lists. Press 3 to add a TODO item. Press 4 to complete a TODO item. Press 5 to exit. Choice: 2 TODO List for susie

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

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions

Question

say if the wff is satisfiable or not. ( A B )

Answered: 1 week ago

Question

=+ d. a professor deciding how much to prepare for class

Answered: 1 week ago