Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Source Code: main.cpp: #include #include Blog.h #include using namespace std; const int MAX =100; int menu(); void addBlog(Blog blog[],int &numBlogs); void displayBlogs(Blog blog[],int numBlogs); void

image text in transcribed

Source Code:

main.cpp:

#include #include "Blog.h" #include

using namespace std; const int MAX =100;

int menu(); void addBlog(Blog blog[],int &numBlogs); void displayBlogs(Blog blog[],int numBlogs); void readBlogs(Blog blog[], int &numBlogs); void writeBlogs(Blog blog[], int numBlogs); void createWebPages (Blog blog[], int numBlogs);

int main() { Blog blog[MAX_BLOGS]; int numBlogs = 0; int choice = 0;

readBlogs(blog, numBlogs); do { choice = menu(); switch (choice) { case 1: // ADD BLOG addBlog(blog, numBlogs); break; case 2: // DISPLAY ALL BLOGS displayBlogs(blog, numBlogs); break; case 3: // CREATE THE WEB PAGES createWebPages(blog, numBlogs); break; case 4: //Create index page case 5: // SAY GOOD BYE cout

writeBlogs(blog, numBlogs); return 0; }

void addBlog(Blog blog[],int &numBlogs) { string authorFirst,authorLast, content; int day,month, year; cout> authorFirst; cout > authorLast; cout> ws; getline (cin, content); cout> month; cout> day; cout> year; blog[numBlogs].setBlog(authorFirst, authorLast, content, month, day, year); numBlogs++; }

void displayBlogs(Blog blog[],int numBlogs) { string authorFirst,authorLast, content; int day,month, year; for(int i=0; i

int menu() { cout > choice; return choice; }

void readBlogs(Blog blog[], int &numBlogs) { ifstream infile("blogs.txt"); numBlogs = 0;

string authorFirst = "", authorLast = "", content = ""; int month = 0, day = 0, year = 0; infile >> authorFirst; while (!infile.eof()) { infile >> authorLast; infile >> ws; getline(infile, content); infile >> month >> day >> year; blog[numBlogs].setBlog(authorFirst, authorLast, content, month, day, year); numBlogs++; infile >> authorFirst; } infile.close(); }

void writeBlogs(Blog blog[], int numBlogs) { ofstream outfile("blogs.txt"); for (int i=0; i

outfile.close(); }

void createWebPages (Blog blog[], int numBlogs) { ofstream outfile; string filename;

for (int i=0; i" " " The CS 355 Super Web Blog" " " Written by " " Blog: " " date: " "

}

Blog.h:

#include using namespace std;

class Blog { private: string authorFirst,authorLast,content; int day, month, year; public: Blog(); void setBlog(string,string,string, int, int, int); string getAuthorFirst()const; string getAuthorLast() const; string getContent() const; int getDay() const; int getMonth() const; int getYear() const; int menu();

};

Blog.cpp:

#include "Blog.h" #include #include

Blog::Blog() { authorFirst=""; authorLast=""; content=""; month=0; day=0; year=0; }

void Blog::setBlog(string authorFirstIn,string authorLastIn,string contentIn, int monthIn, int dayIn, int yearIn) {

authorFirst=authorFirstIn; authorLast=authorLastIn; content=contentIn; month=monthIn; day=dayIn; year=yearIn; }

string Blog::getAuthorFirst()const { return authorFirst; }

string Blog::getAuthorLast() const { return authorLast; }

string Blog::getContent() const { return content; }

int Blog::getDay() const { return day; }

int Blog::getMonth() const { return month; }

int Blog::getYear() const { return year; } int Blog::getDaysElasped() const { const int monthDays [12] ={31,28,31,30,31,30,31,30,31,31,30,31}; // compute days elapsed from 0-0-0000 to blog entry int num = 0; num = 365*year +day; int numLeaps = year/4 - year/100 + year/400; num += numLeaps; for(int i=0; i tm_year; int currMonth = 1 + ltm->tm_mon; int currDay= ltm->tm_mday;

int num2 = 0; num2 = 365*year +day; int numLeaps2 = year/4 - year/100 + year/400; num2 += numLeaps2; for(int i=0; i

}

bool Blog::operator

}

Complete the Web Blog project by doing the following: Create a sort function that will sort the blogs in ascending order of days elapsed. You can use either selection sort or bubble sort. Cite references in the function comment block if you use any external sources. Make sure you are familiar with both selection sort and bubble sort. Create a function that will create the index.html file. It should be valid HTML code. The web page should include a heading at the top of the web page and a hypertext to each of the blog web pages. The links should be displayed from newest to oldest. To accomplish this, your sort function should be called by this function. The web page will look something like that shown below. The author names should be the link. The dates should be included. Each link is included within a paragraph tag. The index page and all of the blog web pages must be written to a folder named website. The CS 355 Super Blog Blog Written by Tom Brady Date: 1-3-2020 Blog Written by Darth Vader Date: 1-3-2016 Blog Written by Shane Banks Date: 9-13-2012 Blog Written by Taylor Swift Date: 10-7-1995 Complete the Web Blog project by doing the following: Create a sort function that will sort the blogs in ascending order of days elapsed. You can use either selection sort or bubble sort. Cite references in the function comment block if you use any external sources. Make sure you are familiar with both selection sort and bubble sort. Create a function that will create the index.html file. It should be valid HTML code. The web page should include a heading at the top of the web page and a hypertext to each of the blog web pages. The links should be displayed from newest to oldest. To accomplish this, your sort function should be called by this function. The web page will look something like that shown below. The author names should be the link. The dates should be included. Each link is included within a paragraph tag. The index page and all of the blog web pages must be written to a folder named website. The CS 355 Super Blog Blog Written by Tom Brady Date: 1-3-2020 Blog Written by Darth Vader Date: 1-3-2016 Blog Written by Shane Banks Date: 9-13-2012 Blog Written by Taylor Swift Date: 10-7-1995

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

Sybase Database Administrators Handbook

Authors: Brian Hitchcock

1st Edition

0133574776, 978-0133574777

More Books

Students also viewed these Databases questions

Question

1. Why do people tell lies on their CVs?

Answered: 1 week ago

Question

2. What is the difference between an embellishment and a lie?

Answered: 1 week ago