SlideShare a Scribd company logo
C++- Help with the section for doEditTweet only.
// Program to implement a very simplified list of tweets
// from a single simulated Twitter account
// Tweets can be added, deleted, and liked
#include <iostream>
using namespace std;
const int MSGSIZE = 100; // Maximum size for a tweet message
const int CAPACITY = 10; // Maximum number of tweets
// Structure used to define a tweet entry
struct Tweet
{
int id;
char msg[MSGSIZE];
int likes;
};
/*
* Prints out an entire timeline to the screen
* timeline = timeline of tweets to be printed
* usedSize = number of tweets in the timeline
* selected = position number of currently selected tweet
*/
void displayTimeline(const Tweet timeline[], int usedSize, int selected);
/*
* Edits currently selected tweet
* with a new message entered by the user.
* timeline = timeline in which the tweet is to be edited
* usedSize = number of tweets in the timeline
* selected = position number of currently selected tweet
* If 'selected' represents a valid array position, the
* selected tweet will be updated.
* If 'selected' is not valid a 'no tweet is selected message' will be
* displayed and no changes will be made.
*/
void doEditTweet(Tweet timeline[], int usedSize, int selected);
/*
* Adds a like to the currently selected tweet.
* timeline = timeline in which the tweet is to be edited
* usedSize = number of tweets in the timeline
* selected = position number of currently selected tweet
* If 'selected' represents a valid array position, the
* selected tweet will be updated.
* If 'selected' is not valid a 'no tweet is selected message' will be
* displayed and no changes will be made.
*/
void doLikeTweet(Tweet timeline[], int usedSize, int selected);
/*
* Deleted currently selected tweet.
* timeline = timeline in from which the entry is to be deleted
* usedSize = number of tweets in the timeline
* If 'selected' represents a valid array position:
* the selected tweet will be deleted
* usedSize will be updated to reflect the updated number of tweets in the timeline
* selected will be updated to -1
* If 'selected' is not valid a 'no tweet is selected message' will be
* displayed and no changes will be made.
*/
void doDeleteTweet(Tweet timeline[], int& usedSize, int& selected);
/*
* If there is room in the timeline for new tweets, then this gets
* a new tweet from the user and adds it to the timeline.
* timeline = timeline in which the tweet is to be added
* usedSize = number of tweets in the timeline
* If tweet was able to be added, returns the position number in the
* timeline of where the item was added, and usedSize will be
* updated to reflect the number of tweets now in the timeline.
* If tweet was not able to be added, returns -1, and usedSize
* remains unchanged.
*/
int doAddTweet(Tweet timeline[], int& usedSize);
/*
* Adds a new tweet to the list
* timeline = timeline in which the entry is to be added
* usedSize = number of tweets in the timeline
* message = tweet message to be added
* If tweet was able to be added, returns the position number in the
* timeline of where the item was added, and usedSize will be
* updated to reflect the number of tweets now in the timeline.
* If tweet was not able to be added, returns -1, and usedSize
* remains unchanged.
*/
int addTweet(Tweet timeline[], int& usedSize, const char message[]);
/*
* Returns the next available ID number
* timeline = timeline in which to find the highest ID
* usedSize = number of tweets in the timeline
* If timeline is empty, returns 100;
* otherwise, returns 1 + highest ID number in the timeline
*/
int getNextId(Tweet timeline[], int usedSize);
/*
* Gets a tweet id from the user. Searches a timeline to try
* to find the specified tweet by its id.
* timeline = timeline to be searched
* usedSize = number of tweets in the timeline
* If the tweet is found, the position number of where the tweet
* is stored in the timeline will be returned. If the tweet is
* not found, a 'not found message' will be printed, and
* the value -1 will be returned.
* If timeline is empty, an 'empty' message will be printed, and
* the value -1 will be returned.
*/
int selectTweet(const Tweet timeline[], int usedSize);
int main()
{
Tweet timeline[CAPACITY]; // Twitter timeline
int choice; // User's menu choice
int usedSize = 0; // Num of tweets in the timeline
int selected = -1; // Currently selected tweet
int tmp; // Temporary variable
// Add some starter entries for testing purposes
selected = addTweet(timeline, usedSize, "Where do they get the seeds to plant seedless
watermelons?");
selected = addTweet(timeline, usedSize, "Waffles are just pancakes with convenient boxes to hold
your syrup.");
selected = addTweet(timeline, usedSize, "Last night I even struck up a conversation with a spider.
Turns out he's a web designer.");
do
{
cout << "1. Display Timelinen";
cout << "2. Select Tweetn";
cout << "3. Add New Tweetn";
cout << "4. Edit Selected Tweetn";
cout << "5. Like Selected Tweetn";
cout << "6. Delete Tweetn";
cout << "7. Exitn";
cout << endl;
cout << "Select: ";
// Get the numeric entry from the menu
cin >> choice;
// Corrects issues where user might enter a non-integer value
while (cin.fail())
{
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), 'n');
cout << "Select: ";
cin >> choice;
}
// Makes the 'enter' key that was pressed after the numeric entry be ignored
// Should be used after getting any numeric input from the keyboard
cin.ignore();
switch (choice)
{
case 1:
displayTimeline(timeline, usedSize, selected);
break;
case 2:
tmp = selectTweet(timeline, usedSize);
// if selected tweet exists, update selected variable;
// otherwise leave it unchanged
if (tmp > -1)
selected = tmp;
break;
case 3:
tmp = doAddTweet(timeline, usedSize);
// if tweet was added, make it be the selected tweet;
// otherwise leave it unchanged
if (tmp > -1)
selected = tmp;
break;
case 4:
doEditTweet(timeline, usedSize, selected);
break;
case 5:
doLikeTweet(timeline, usedSize, selected);
break;
case 6:
doDeleteTweet(timeline, usedSize, selected);
break;
}
} while (choice != 7);
return 0;
}
int doAddTweet(Tweet timeline[], int& usedSize)
{
// TODO: Write code for the function
return -1;
}
void doEditTweet(Tweet timeline[], int usedSize, int selected)
{
// TODO: Write code for the function
}
void doLikeTweet(Tweet timeline[], int usedSize, int selected)
{
// TODO: Write code for the function
}
void displayTimeline(const Tweet timeline[], int usedSize, int selected)
{
// TODO: Write code for the function
}
int addTweet(Tweet timeline[], int& usedSize, const char message[])
{
// TODO: Write code for the function
return -1;
}
int getNextId(Tweet timeline[], int usedSize)
{
// TODO: Write code for the function
return 100;
}
void doDeleteTweet(Tweet timeline[], int& usedSize, int& selected)
{
if (selected == -1)
{
cout << "no tweet is selected" << endl;
}
else
{
selected = -1;
usedSize = usedSize - 1;
}
}
int selectTweet(const Tweet timeline[], int usedSize)
{
return -1;
}

More Related Content

More from jaipur2

Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdf
Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdfBu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdf
Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdf
jaipur2
 
BU Contractors received a contract to construct an office bu.pdf
BU Contractors received a contract to construct an office bu.pdfBU Contractors received a contract to construct an office bu.pdf
BU Contractors received a contract to construct an office bu.pdf
jaipur2
 
Bu senaryo bir geici zm en iyi ekilde aklar Etkili.pdf
Bu senaryo bir geici zm en iyi ekilde aklar   Etkili.pdfBu senaryo bir geici zm en iyi ekilde aklar   Etkili.pdf
Bu senaryo bir geici zm en iyi ekilde aklar Etkili.pdf
jaipur2
 
Bu durum iin tam binom olaslk dalmn sadaki bir tabloda olut.pdf
Bu durum iin tam binom olaslk dalmn sadaki bir tabloda olut.pdfBu durum iin tam binom olaslk dalmn sadaki bir tabloda olut.pdf
Bu durum iin tam binom olaslk dalmn sadaki bir tabloda olut.pdf
jaipur2
 
Bu derste T hcreleri iin merkezi ve evresel tolerans mek.pdf
Bu derste T hcreleri iin merkezi ve evresel tolerans mek.pdfBu derste T hcreleri iin merkezi ve evresel tolerans mek.pdf
Bu derste T hcreleri iin merkezi ve evresel tolerans mek.pdf
jaipur2
 
Bullseye Corp is a private company in the state of Illinois .pdf
Bullseye Corp is a private company in the state of Illinois .pdfBullseye Corp is a private company in the state of Illinois .pdf
Bullseye Corp is a private company in the state of Illinois .pdf
jaipur2
 
Bulging and herniated discs can cause major problems when th.pdf
Bulging and herniated discs can cause major problems when th.pdfBulging and herniated discs can cause major problems when th.pdf
Bulging and herniated discs can cause major problems when th.pdf
jaipur2
 
Bullying according to noted expert Dan Olweus poisons t.pdf
Bullying according to noted expert Dan Olweus poisons t.pdfBullying according to noted expert Dan Olweus poisons t.pdf
Bullying according to noted expert Dan Olweus poisons t.pdf
jaipur2
 
C++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdfC++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdf
jaipur2
 
C++ only plz Write a function that takes two arguments and .pdf
C++ only  plz Write a function that takes two arguments and .pdfC++ only  plz Write a function that takes two arguments and .pdf
C++ only plz Write a function that takes two arguments and .pdf
jaipur2
 
C++ only 319 LAB Exact change Write a program with total c.pdf
C++ only 319 LAB Exact change Write a program with total c.pdfC++ only 319 LAB Exact change Write a program with total c.pdf
C++ only 319 LAB Exact change Write a program with total c.pdf
jaipur2
 
C++ is a highlevel programming language that consists of v.pdf
C++ is a highlevel programming language that consists of v.pdfC++ is a highlevel programming language that consists of v.pdf
C++ is a highlevel programming language that consists of v.pdf
jaipur2
 
C++ Help with the section for getNextId only Program to.pdf
C++ Help with the section for getNextId only  Program to.pdfC++ Help with the section for getNextId only  Program to.pdf
C++ Help with the section for getNextId only Program to.pdf
jaipur2
 
C++ Programming Exercise 9 from Chapter 16 Upload your so.pdf
C++  Programming Exercise 9 from Chapter 16 Upload your so.pdfC++  Programming Exercise 9 from Chapter 16 Upload your so.pdf
C++ Programming Exercise 9 from Chapter 16 Upload your so.pdf
jaipur2
 
BU RESTORAN KURTARILABLR M Juan ve Bonita Gonzales Ohio .pdf
BU RESTORAN KURTARILABLR M  Juan ve Bonita Gonzales Ohio .pdfBU RESTORAN KURTARILABLR M  Juan ve Bonita Gonzales Ohio .pdf
BU RESTORAN KURTARILABLR M Juan ve Bonita Gonzales Ohio .pdf
jaipur2
 
C Sao Paulodaki Lumiar okulunda snf ev devi veya oyun zam.pdf
C Sao Paulodaki Lumiar okulunda snf ev devi veya oyun zam.pdfC Sao Paulodaki Lumiar okulunda snf ev devi veya oyun zam.pdf
C Sao Paulodaki Lumiar okulunda snf ev devi veya oyun zam.pdf
jaipur2
 
Bu eitim modlnde sunulan biyolojik tehlike tanmndaki gve.pdf
Bu eitim modlnde sunulan biyolojik tehlike tanmndaki gve.pdfBu eitim modlnde sunulan biyolojik tehlike tanmndaki gve.pdf
Bu eitim modlnde sunulan biyolojik tehlike tanmndaki gve.pdf
jaipur2
 
C problem 1 Create Ellipse object Ellipse set fill to Col.pdf
C problem 1 Create Ellipse object Ellipse set fill to Col.pdfC problem 1 Create Ellipse object Ellipse set fill to Col.pdf
C problem 1 Create Ellipse object Ellipse set fill to Col.pdf
jaipur2
 
C Program Jrite a program called that prompts the user to en.pdf
C Program Jrite a program called that prompts the user to en.pdfC Program Jrite a program called that prompts the user to en.pdf
C Program Jrite a program called that prompts the user to en.pdf
jaipur2
 
c Design a Turing Machine for the following language Lab.pdf
c Design a Turing Machine for the following language Lab.pdfc Design a Turing Machine for the following language Lab.pdf
c Design a Turing Machine for the following language Lab.pdf
jaipur2
 

More from jaipur2 (20)

Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdf
Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdfBu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdf
Bu yaz kamyonu farkl yerel topluluk etkinliklerine gtryor.pdf
 
BU Contractors received a contract to construct an office bu.pdf
BU Contractors received a contract to construct an office bu.pdfBU Contractors received a contract to construct an office bu.pdf
BU Contractors received a contract to construct an office bu.pdf
 
Bu senaryo bir geici zm en iyi ekilde aklar Etkili.pdf
Bu senaryo bir geici zm en iyi ekilde aklar   Etkili.pdfBu senaryo bir geici zm en iyi ekilde aklar   Etkili.pdf
Bu senaryo bir geici zm en iyi ekilde aklar Etkili.pdf
 
Bu durum iin tam binom olaslk dalmn sadaki bir tabloda olut.pdf
Bu durum iin tam binom olaslk dalmn sadaki bir tabloda olut.pdfBu durum iin tam binom olaslk dalmn sadaki bir tabloda olut.pdf
Bu durum iin tam binom olaslk dalmn sadaki bir tabloda olut.pdf
 
Bu derste T hcreleri iin merkezi ve evresel tolerans mek.pdf
Bu derste T hcreleri iin merkezi ve evresel tolerans mek.pdfBu derste T hcreleri iin merkezi ve evresel tolerans mek.pdf
Bu derste T hcreleri iin merkezi ve evresel tolerans mek.pdf
 
Bullseye Corp is a private company in the state of Illinois .pdf
Bullseye Corp is a private company in the state of Illinois .pdfBullseye Corp is a private company in the state of Illinois .pdf
Bullseye Corp is a private company in the state of Illinois .pdf
 
Bulging and herniated discs can cause major problems when th.pdf
Bulging and herniated discs can cause major problems when th.pdfBulging and herniated discs can cause major problems when th.pdf
Bulging and herniated discs can cause major problems when th.pdf
 
Bullying according to noted expert Dan Olweus poisons t.pdf
Bullying according to noted expert Dan Olweus poisons t.pdfBullying according to noted expert Dan Olweus poisons t.pdf
Bullying according to noted expert Dan Olweus poisons t.pdf
 
C++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdfC++ Please I am posting the fifth time and hoping to get th.pdf
C++ Please I am posting the fifth time and hoping to get th.pdf
 
C++ only plz Write a function that takes two arguments and .pdf
C++ only  plz Write a function that takes two arguments and .pdfC++ only  plz Write a function that takes two arguments and .pdf
C++ only plz Write a function that takes two arguments and .pdf
 
C++ only 319 LAB Exact change Write a program with total c.pdf
C++ only 319 LAB Exact change Write a program with total c.pdfC++ only 319 LAB Exact change Write a program with total c.pdf
C++ only 319 LAB Exact change Write a program with total c.pdf
 
C++ is a highlevel programming language that consists of v.pdf
C++ is a highlevel programming language that consists of v.pdfC++ is a highlevel programming language that consists of v.pdf
C++ is a highlevel programming language that consists of v.pdf
 
C++ Help with the section for getNextId only Program to.pdf
C++ Help with the section for getNextId only  Program to.pdfC++ Help with the section for getNextId only  Program to.pdf
C++ Help with the section for getNextId only Program to.pdf
 
C++ Programming Exercise 9 from Chapter 16 Upload your so.pdf
C++  Programming Exercise 9 from Chapter 16 Upload your so.pdfC++  Programming Exercise 9 from Chapter 16 Upload your so.pdf
C++ Programming Exercise 9 from Chapter 16 Upload your so.pdf
 
BU RESTORAN KURTARILABLR M Juan ve Bonita Gonzales Ohio .pdf
BU RESTORAN KURTARILABLR M  Juan ve Bonita Gonzales Ohio .pdfBU RESTORAN KURTARILABLR M  Juan ve Bonita Gonzales Ohio .pdf
BU RESTORAN KURTARILABLR M Juan ve Bonita Gonzales Ohio .pdf
 
C Sao Paulodaki Lumiar okulunda snf ev devi veya oyun zam.pdf
C Sao Paulodaki Lumiar okulunda snf ev devi veya oyun zam.pdfC Sao Paulodaki Lumiar okulunda snf ev devi veya oyun zam.pdf
C Sao Paulodaki Lumiar okulunda snf ev devi veya oyun zam.pdf
 
Bu eitim modlnde sunulan biyolojik tehlike tanmndaki gve.pdf
Bu eitim modlnde sunulan biyolojik tehlike tanmndaki gve.pdfBu eitim modlnde sunulan biyolojik tehlike tanmndaki gve.pdf
Bu eitim modlnde sunulan biyolojik tehlike tanmndaki gve.pdf
 
C problem 1 Create Ellipse object Ellipse set fill to Col.pdf
C problem 1 Create Ellipse object Ellipse set fill to Col.pdfC problem 1 Create Ellipse object Ellipse set fill to Col.pdf
C problem 1 Create Ellipse object Ellipse set fill to Col.pdf
 
C Program Jrite a program called that prompts the user to en.pdf
C Program Jrite a program called that prompts the user to en.pdfC Program Jrite a program called that prompts the user to en.pdf
C Program Jrite a program called that prompts the user to en.pdf
 
c Design a Turing Machine for the following language Lab.pdf
c Design a Turing Machine for the following language Lab.pdfc Design a Turing Machine for the following language Lab.pdf
c Design a Turing Machine for the following language Lab.pdf
 

Recently uploaded

The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 

Recently uploaded (20)

The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 

C++ Help with the section for doEditTweet only Program .pdf

  • 1. C++- Help with the section for doEditTweet only. // Program to implement a very simplified list of tweets // from a single simulated Twitter account // Tweets can be added, deleted, and liked #include <iostream> using namespace std; const int MSGSIZE = 100; // Maximum size for a tweet message const int CAPACITY = 10; // Maximum number of tweets // Structure used to define a tweet entry struct Tweet { int id; char msg[MSGSIZE]; int likes; }; /* * Prints out an entire timeline to the screen * timeline = timeline of tweets to be printed * usedSize = number of tweets in the timeline * selected = position number of currently selected tweet */ void displayTimeline(const Tweet timeline[], int usedSize, int selected); /* * Edits currently selected tweet * with a new message entered by the user. * timeline = timeline in which the tweet is to be edited * usedSize = number of tweets in the timeline * selected = position number of currently selected tweet * If 'selected' represents a valid array position, the * selected tweet will be updated. * If 'selected' is not valid a 'no tweet is selected message' will be * displayed and no changes will be made. */ void doEditTweet(Tweet timeline[], int usedSize, int selected); /* * Adds a like to the currently selected tweet. * timeline = timeline in which the tweet is to be edited * usedSize = number of tweets in the timeline * selected = position number of currently selected tweet * If 'selected' represents a valid array position, the * selected tweet will be updated. * If 'selected' is not valid a 'no tweet is selected message' will be * displayed and no changes will be made.
  • 2. */ void doLikeTweet(Tweet timeline[], int usedSize, int selected); /* * Deleted currently selected tweet. * timeline = timeline in from which the entry is to be deleted * usedSize = number of tweets in the timeline * If 'selected' represents a valid array position: * the selected tweet will be deleted * usedSize will be updated to reflect the updated number of tweets in the timeline * selected will be updated to -1 * If 'selected' is not valid a 'no tweet is selected message' will be * displayed and no changes will be made. */ void doDeleteTweet(Tweet timeline[], int& usedSize, int& selected); /* * If there is room in the timeline for new tweets, then this gets * a new tweet from the user and adds it to the timeline. * timeline = timeline in which the tweet is to be added * usedSize = number of tweets in the timeline * If tweet was able to be added, returns the position number in the * timeline of where the item was added, and usedSize will be * updated to reflect the number of tweets now in the timeline. * If tweet was not able to be added, returns -1, and usedSize * remains unchanged. */ int doAddTweet(Tweet timeline[], int& usedSize); /* * Adds a new tweet to the list * timeline = timeline in which the entry is to be added * usedSize = number of tweets in the timeline * message = tweet message to be added * If tweet was able to be added, returns the position number in the * timeline of where the item was added, and usedSize will be * updated to reflect the number of tweets now in the timeline. * If tweet was not able to be added, returns -1, and usedSize * remains unchanged. */ int addTweet(Tweet timeline[], int& usedSize, const char message[]); /* * Returns the next available ID number * timeline = timeline in which to find the highest ID * usedSize = number of tweets in the timeline * If timeline is empty, returns 100; * otherwise, returns 1 + highest ID number in the timeline
  • 3. */ int getNextId(Tweet timeline[], int usedSize); /* * Gets a tweet id from the user. Searches a timeline to try * to find the specified tweet by its id. * timeline = timeline to be searched * usedSize = number of tweets in the timeline * If the tweet is found, the position number of where the tweet * is stored in the timeline will be returned. If the tweet is * not found, a 'not found message' will be printed, and * the value -1 will be returned. * If timeline is empty, an 'empty' message will be printed, and * the value -1 will be returned. */ int selectTweet(const Tweet timeline[], int usedSize); int main() { Tweet timeline[CAPACITY]; // Twitter timeline int choice; // User's menu choice int usedSize = 0; // Num of tweets in the timeline int selected = -1; // Currently selected tweet int tmp; // Temporary variable // Add some starter entries for testing purposes selected = addTweet(timeline, usedSize, "Where do they get the seeds to plant seedless watermelons?"); selected = addTweet(timeline, usedSize, "Waffles are just pancakes with convenient boxes to hold your syrup."); selected = addTweet(timeline, usedSize, "Last night I even struck up a conversation with a spider. Turns out he's a web designer."); do { cout << "1. Display Timelinen"; cout << "2. Select Tweetn"; cout << "3. Add New Tweetn"; cout << "4. Edit Selected Tweetn"; cout << "5. Like Selected Tweetn"; cout << "6. Delete Tweetn"; cout << "7. Exitn"; cout << endl; cout << "Select: "; // Get the numeric entry from the menu cin >> choice; // Corrects issues where user might enter a non-integer value
  • 4. while (cin.fail()) { cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), 'n'); cout << "Select: "; cin >> choice; } // Makes the 'enter' key that was pressed after the numeric entry be ignored // Should be used after getting any numeric input from the keyboard cin.ignore(); switch (choice) { case 1: displayTimeline(timeline, usedSize, selected); break; case 2: tmp = selectTweet(timeline, usedSize); // if selected tweet exists, update selected variable; // otherwise leave it unchanged if (tmp > -1) selected = tmp; break; case 3: tmp = doAddTweet(timeline, usedSize); // if tweet was added, make it be the selected tweet; // otherwise leave it unchanged if (tmp > -1) selected = tmp; break; case 4: doEditTweet(timeline, usedSize, selected); break; case 5: doLikeTweet(timeline, usedSize, selected); break; case 6: doDeleteTweet(timeline, usedSize, selected); break; } } while (choice != 7); return 0; }
  • 5. int doAddTweet(Tweet timeline[], int& usedSize) { // TODO: Write code for the function return -1; } void doEditTweet(Tweet timeline[], int usedSize, int selected) { // TODO: Write code for the function } void doLikeTweet(Tweet timeline[], int usedSize, int selected) { // TODO: Write code for the function } void displayTimeline(const Tweet timeline[], int usedSize, int selected) { // TODO: Write code for the function } int addTweet(Tweet timeline[], int& usedSize, const char message[]) { // TODO: Write code for the function return -1; } int getNextId(Tweet timeline[], int usedSize) { // TODO: Write code for the function return 100; } void doDeleteTweet(Tweet timeline[], int& usedSize, int& selected) { if (selected == -1) { cout << "no tweet is selected" << endl; } else { selected = -1; usedSize = usedSize - 1; } }
  • 6. int selectTweet(const Tweet timeline[], int usedSize) { return -1; }