Program to create a class and store student information, C/C++ Programming

Assignment Help:

Develop a Student class that has the following header file:

#ifndef STUDENT_H

#define STUDENT_H

#include

#include

#include

using namespace std;

class Student{

public:

Student();

Student(string name,string surname,int a1, int a2, int test, int exam);

string getName()const;

string getSurname()const;

int getAssignment1Mark()const;

int getAssignment2Mark()const;

int getLabTestMark()const;

int getExamMark()const;

void setAssignment1Mark(int);

void setAssignment2Mark(int);

void setLabTestMark(int);

void setExamMark(int);

bool passed()const;

string getGrade()const;

friend ostream& operator<<(ostream& stream, const Student &);

bool operator<(const Student &)const;

private:

string name;

string surname;

int assignment1Mark;

int assignment2Mark;

int labTestMark;

int examMark;

};

#endif

You are required to implement the class, i.e. to develop the implementation file "Student.cpp" that conforms to the following specifications:

(1) The data fields have self explanatory identifiers, and their meaning should be clear from the Introduction.

(2) The "set" functions allow the user to set the assessment task marks within the specified margins, e.g. setExamMark ensures that the examMark is in the appropriate range - from 0 to 50.

 (3) The function getGrade() returns the student's grade, calculated as specified in the Introduction. The rest of the "get" functions simply return the values of the corresponding fields.

 (4) The function passed() returns true if this student , has passed the course, and returns false otherwise (see the Introduction).

 (5) friend ostream& operator<<(ostream& stream, const Student &) - the function overloads << operator, which allows a Student object information to be output in the following format:

Underwood Scott:

Assignment 1 8

Assignment 2 16

Lab Test 0

Exam 34

Grade P

(6) bool operator<(const Student &student)const - the function overloads < operator, which allows to compare student's full names lexicographically.

2. Class ITECH7603Class.

The class has the following header file. Objects of this class represent ITECH7603 teaching classes (student groups).

#ifndef ITECH7603CLASS_H

#define ITECH7603CLASS_H

#include "Student.h"

#include

#include

#include

class ITECH7603Class{

public:

ITECH7603Class();

ITECH7603Class(int dummy);

ITECH7603Class(set*);

~ITECH7603Class();

void addStudent(Student*);

map* getGroup();

void save();

private:

map* group;

};

#endif

You are required to implement the class, i.e. to develop the implementation file "ITECH7603Class.cpp" that conforms to the following specifications:

(1) The only field of the class is a pointer to a "map" object representing a teaching group(or class), which is a map (an associative STL container) that contains the pairs:

Key: a student's full name (i.e. name + " " + surname)

Value: corresponding Student object.

In this assignment you should assume that there are no different students with identical full names in ITECH7603 teaching classes.

(2) void addStudent(Student* studentPtr)- the function adds the pair

Key: (*studentPtr) student's full name

Value: (*studentPtr)

To the (*group) map;

Please note that instead of actual objects you are supposed to use pointers as function parameters.

 (3) void save()- the function writes the Student objects stored as values in the (*group) map to the "ITECH7603Students.bin" file. "ITECH7603Students.bin" is a binary file, and you are required to write the objects to the file using something like

out.write(reinterpret_cast(s), sizeof(Student));

 (4) Constructor ITECH7603Class() and the destructor:

A default constructor initializes dynamically the group field.

The destructor deletes the group pointer.

 (5) Constructor ITECH7603Class(int dummy):

This constructor does not require any parameter. However, to distinguish it from the default constructor you should use some dummy argument (say of int type). This constructor opens the "ITECH7603Students.bin" file, if such file exists, and reads information from the file into the (*group) map using addStudent() function. If the file "ITECH7603Students.bin" does not exist, the constructor behaves as the default constructor.

 (6) Constructor ITECH7603Class(set* students):

This constructor takes a set of Student objects (in fact, a pointer to the set) as an argument and adds students from the set to the (*group) map, i.e. initializes the group field.

3. TestAssignment2.cpp

This is a test program that tests the Student and ITECH7603Class classes.

In this assignment you are provided with three input text files associated with this program:

  • firstNamesBoys.txt - contains first names for boys
  • firstNamesGirls.txt - contains first names for girls
  • lastNames.txt - contains last names

Each of these input files contains one name per line. Hence "firstNamesBoys.txt" will contain one boy's name per line, and "lastNames.txt" contains one surname per line. These input files will be used to create a random set of Student objects to test your application.


Related Discussions:- Program to create a class and store student information

C program to find the even words in the string, C Program to FIND THE EVEN ...

C Program to FIND THE EVEN WORDS IN THE STRING #include conio.h> #include stdio.h> void main() {           char a[50],temp;           int i=0,k=0,l[25],c=0,r=0;

Application for tag in the forest game, Your program should use the Free Pa...

Your program should use the Free Pascal compiler or the Lazarus IDE described in CSC 540. When you hand in your assignment to the digital dropbox, it should be a .PAS file, not zip

Lexicographically preceding permutation, Respected Sir, I want the above wr...

Respected Sir, I want the above written text in a C program

Lexicographically preceding permutation, Given an integer n and a permutati...

Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given

Why php is also known as scripting language, Why PHP is also known as scrip...

Why PHP is also known as scripting language? PHP is fundamentally a general purpose language, which is used to write scripts. Scripts are normal computer files which comprises

Explain logical operators, Logical Operators We say any expression that...

Logical Operators We say any expression that evaluates to zero is a FALSE logic condition and that evaluating to non-zero value is a TRUE condition. Logical operators are usefu

Explain pros and cons of cpp as a programming language, Write a 3-4 page pa...

Write a 3-4 page paper (350 words per page) in APA format detailing the development and use of C++ in academia and in industry. Explain the pros and cons of C++ as a programming la

Array, how to do an array

how to do an array

Objects as function arguments, Objects as Function Arguments: In C prog...

Objects as Function Arguments: In C program there are several methods to define arguments, and in some case even a structure can be approved as an argument.  Similarly in C+

Luminous Jewels - Polishing Necklace, Byteland county is very famous for lu...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd