Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are to implement a program scheduling a teachers daily schedule. The list of requirements and constraints for the system are as follows: The system

You are to implement a program scheduling a teachers daily schedule. The list of requirements and constraints for the system are as follows:

The system will be used to manage grades of various students in a class

The name of each student is unique and can be used to locate the information on a specific patient or time slot. User can print all grade information. Code organization Read the provided files for detailed instructions on each class, and class members!

main.cpp

The main entry point of the executable. Set up the app class and run it. Provided file, do not modify!

Grade Class

The class to handle information of a single grade (one grade per student)

Gradebook Class

The class to manage grades.

TextMenuApp Class

The main application class the drives a text menu based program. When reading in the student's name, make sure you handle the getline after extraction problem!

makefile

The makefile is provided. Do not modify!

Implementation Notes

. You may run the main-linux under Linux or WSL to try how the program works.

All header files are provided.

They provided the information about that needs to be implemented. Do not modify them.

Make the corresponding cpp files as needed.

Follow the file naming convention. You can run make or make main to compile your app and execute using ./main

A makefile rule named test is provided and you can run it using make test to run the provided tests on the Grade and GradeBook classes.

Run make testrun to reproduce the sample run shown in the instruction.

text-menu-app.hpp

#ifndef TEXT_MENU_APP_HPP #define TEXT_MENU_APP_HPP #include "gradebook.hpp" #include class TextMenuApp { GradeBook &gradeBook; public: // Provided constructor // initialize the gradeBook instance variable explicit TextMenuApp(GradeBook &gradeBook) : gradeBook(gradeBook) {}; // drives the main logic of the text menu app void run(); }; #endif // TEXT_MENU_APP_HPP

main.cpp

#include "grade.hpp" #include "gradebook.hpp" #include "text-menu-app.hpp" int main() { // create initial data of a sample gradebook GradeBook gradeBook("COP 3014"); gradeBook.addGrade("John Smith", 90); gradeBook.addGrade("Laura Johnson", 83); gradeBook.addGrade("Josh Brown", 77); // create and run the text menu based app TextMenuApp menu(gradeBook); menu.run(); return EXIT_SUCCESS; }

gradebook.hpp

#ifndef GRADEBOOK_HPP #define GRADEBOOK_HPP #include "grade.hpp" #include class GradeBook { std::string courseName; Grade grades[40]; // hold 40 grades at most, assuming it is enough int count = 0; public: // default constructor GradeBook(); // parameterized constructor to set the initial values of // all instance variables GradeBook(const std::string &courseName); // getter of the count of students int getCount() const; // getter of the course name std::string getName() const; // add a new grade // do not worry about the size limit void addGrade(const std::string &name, double grade); // search the grade by student's name // return -1 if not found int searchStudent(const std::string &name) const; // print the student's info providing a valid index // assuming that the index is valid (get from the search) // ask the Grade object to print void printStudent(int studentIndex) const; // print a summary of the course like: // Gradebook of course COP 3014 // Name: John Smith | Grade: 90.0 // Name: Laura Johnson | Grade: 83.0 // Name: Josh Brown | Grade: 77.0 // ask each Grade object to print itself void print() const; }; #endif // GRADEBOOK_HPP

grade.hpp

#ifndef GRADE_HPP #define GRADE_HPP #include class Grade { std::string studentName; double grade; public: // default constructor Grade(); // parameterized constructor to set the initial values of // all instance variables Grade(const std::string &name, double grade); // getter of the student's name std::string getName() const; // getter of the grade double getGrade() const; // print the grade info in the format like: // Name: Jerry Williams | Grade: 78.0 // should display one decimal place void print() const; }; #endif // GRADE_HPP

test.cpp

#include "grade.hpp" #include "gradebook.hpp" #include #include #include using namespace std; bool isClose(double v1, double v2) { double epsilon = 1e-4; return fabs(v1 - v2) < epsilon; } void testGrade() { cout << "Testing grade class" << endl; Grade grade; assert(grade.getName().empty()); Grade grade1("new name", 90); assert(grade1.getName() == "new name"); assert(isClose(grade1.getGrade(), 90)); grade1.print(); } void testGradeBook() { cout << "Testing grade book class" << endl; GradeBook gradeBook("COP3014"); gradeBook.addGrade("John Smith", 92); assert(gradeBook.getName() == "COP3014"); assert(gradeBook.searchStudent("invalid student") == -1); assert(gradeBook.searchStudent("John Smith") == 0); gradeBook.print(); } int main() { testGrade(); testGradeBook(); cout << "All test passed!" << endl; return EXIT_SUCCESS; }

makefile

SHELL=/bin/bash TARGETS=main test CXX=g++ FLAGS=-std=c++11 -Wall RM=rm -rf .PHONY: clean # Target rules main: main.o text-menu-app.o gradebook.o grade.o $(CXX) -o $@ $^ test: test.o gradebook.o grade.o $(CXX) -o $@ $^ ./test # General compilation rules %.o: %.cpp $(CXX) $(FLAGS) -c $< # Rule to test run your code with the exact same input used in the sample run testrun: main echo -e "1 2 Bad Name John Smith 3 Jerry Williams 123 -5 78 1 4 " | ./main clean: $(RM) .o $(TARGETS).gc* *.dSYM

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

More Books

Students also viewed these Databases questions