Create a new project named lab9_1 . You will need to implement a Course class. Here is its UML diagram: Course - department  : string - course_num : string - section     : int - num_students : int - is_full     : bool + Course() + Course(string, string, int, int) + setDepartment(string) : void + setNumber(string) : void + setSection(int) : void + setStudents(int) : void + getDepartment() const : string + getNumber() const : string + getSection() const : int + getStudents() const : int + print() const : void  Create a sample file to read from: CSS 2A 1111 35 Additional information: The Course class has two constructors. Make sure you have default values for your default constructor. Each course maxes out at 40 students. Therefore, you need to make sure that there aren’t more than 40 students in a Course. You can choose how you handle situations where more than 40 students are added. Additionally, you should automatically set is_full to false or true, based on the number of students. If you’d like to include additional methods than those found in the UML diagram, feel free to do so. That’s just the minimum amount required, but helper/utility methods would be okay. You will also make use of the const keyword to indicate which methods are not modifying the object. You will read in the information from the file, and declare a Course object to store this data. Then you will print a summary of the course. Then, modify st_enrolled to have 40 student (just use setStudents() method), and then print the summary once more. Your main function may start out: Course myclass; string dep, c_num; int sec, num_stus; ifstream fin("file.txt"); if(fin.fail()) { cout << "File path is bad\n"; exit(1); } fin >> dep >> c_num >> sec >> num_stus; fin.close(); myclass.setDepartment(dep); myclass.setNumber(c_num); //and continue Sample run: ----------------------------- Course: CSS 2A, Section: 1111 Enrolled: 35, Status: Open ----------------------------- Another sample run (notice since class is full, Status is set to closed): ----------------------------- Course: CSS 2A, Section: 1111 Enrolled: 40, Status: Closed -----------------------------

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter1: A First Program Using C#
Section: Chapter Questions
Problem 12RQ
icon
Related questions
Question

In C++

 

 Create a new project named lab9_1 . You will need to implement a Course class. Here is its UML diagram:

Course
- department  : string
- course_num : string
- section     : int
- num_students : int
- is_full     : bool
+ Course()
+ Course(string, string, int, int)
+ setDepartment(string) : void
+ setNumber(string) : void
+ setSection(int) : void
+ setStudents(int) : void
+ getDepartment() const : string
+ getNumber() const : string
+ getSection() const : int
+ getStudents() const : int
+ print() const : void

 Create a sample file to read from:

CSS 2A 1111 35

Additional information:

  1. The Course class has two constructors. Make sure you have default values for your default constructor.

  2. Each course maxes out at 40 students. Therefore, you need to make sure that there aren’t more than 40 students in a Course. You can choose how you handle situations where more than 40 students are added. Additionally, you should automatically set is_full to false or true, based on the number of students.

  3. If you’d like to include additional methods than those found in the UML diagram, feel free to do so. That’s just the minimum amount required, but helper/utility methods would be okay.

  4. You will also make use of the const keyword to indicate which methods are not modifying the object.

  5. You will read in the information from the file, and declare a Course object to store this data. Then you will print a summary of the course. Then, modify st_enrolled to have 40 student (just use setStudents() method), and then print the summary once more.

Your main function may start out:

Course myclass;
string dep, c_num;
int sec, num_stus;
ifstream fin("file.txt");
if(fin.fail())
{
cout << "File path is bad\n";
exit(1);
}

fin >> dep >> c_num >> sec >> num_stus;

fin.close();

myclass.setDepartment(dep);
myclass.setNumber(c_num);

//and continue

Sample run:

-----------------------------
Course: CSS 2A, Section: 1111
Enrolled: 35, Status: Open
-----------------------------

Another sample run (notice since class is full, Status is set to closed):

-----------------------------
Course: CSS 2A, Section: 1111
Enrolled: 40, Status: Closed
-----------------------------

2. Create a new project named lab9_2. You will continue to use the Courses class, but this time you will create a vector of Courses. The file you will read from is below:

6
CSS 2A 1111 35
CSS 2A 2222 20
CSS 1 3333 40
CSS 1 4444 33
CSS 3 5555 15
CSS 44 6666 12

Read this information into a vector of Courses. Then, print out a summary of your vector.

Here's a sample driver:

#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <cstdlib>
#include "Course.h"
using namespace std;

int main()
{
vector<Course> myclass;
string dep, c_num;
int classes, sec, num_stus;
ifstream fin("sample.txt");
if (fin.fail())
{
cout << "File path is bad\n";
exit(1);
}

fin >> classes;

for (int i = 0; i < classes; i++)
{
fin >> dep >> c_num >> sec >> num_stus;
// Now how do you create a Course object
// that contains the information you just read in
// and add it to your myclass vector?
}

cout << "Here are the college courses: " << endl;

for (Course& c : myclass)
{
c.print();
}

return 0;
}

Sample run:

Here are the college courses:
-----------------------------
Course: CSS 2A, Section: 1111
Enrolled: 35, Status: Open
-----------------------------
Course: CSS 2A, Section: 2222
Enrolled: 20, Status: Open
-----------------------------
Course: CSS 1, Section: 3333
Enrolled: 40, Status: Closed
-----------------------------
Course: CSS 1, Section: 4444
Enrolled: 33, Status: Open
-----------------------------
Course: CSS 3, Section: 5555
Enrolled: 15, Status: Open
-----------------------------
Course: CSS 44, Section: 6666
Enrolled: 12, Status: Open
-----------------------------

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Software Development
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,