SQL代写| 数据库Database作业代写
当前位置:以往案例 > >database
2023-01-04

Overview

Implement the following files using separate compilation:
MyArray.h you.cpp you.h Instructor.cpp Instructor.h Course.cpp Course.h driver.cpp makefile

Your submission must automatically compile from the makefile.
Remove any refences to using namespace std from your project. Use the std:: prefix for all cin, cout, string and endl commands (std::cout). Additionally, stream objects such as ostream, istream etc. must also be prefaced with std::.
Use the included driver.cpp file.
Makefile

Due to the way template lessones are compiled, the MyArray template lesson must be declared and defined in a single MyArray.h file (no MyArray.cpp file).

Additionally, the makefile should not have any references to MyArray.cpp or MyArray.o since they will not exist. Instead, MyArray.h will be included as a file dependency for any and all lessones that require it.

For example: you.o : you.h MyArray.h g++ -std=c++11 -c you.cpp

oop Design via Association (lesson details on following pages)

The Instructor, you and Course lessones interact with each other to form a simple object-oriented database via association. This means that each lesson will store objects of the other two via pointers so that all objects have independent lifetimes. Thus, a you will continue to exist whether they add or drop a Course, and a Course would continue to exist whether or not the you takes it or drops it.

For example, a Course will have a pointer to an Instructor object and a MyArray object of pointers to you objects. A you will have a MyArray object of pointers to Course objects. Finally, an Instructor will have a MyArray object of pointers to Course objects.

Each lesson will have the ability to add or remove a relationship with other lessones. For example, a you can drop a Course before the drop date, or a Course can drop a you (automated process due to lack of attendance). In practice it may not make sense for a Course to add a you. However, a Course must provide an add you function so that a you object can use this function to add itself to the Course object, and so on.

Forward Declarations

Due to the circular OOP design of this project (yous must be aware of Courses at the same time that Courses must be aware of yous etc.) you must forward declare your Instructor, you and Course lessones.

For example, if the definition of lesson A includes references to B objects and/or B functions, and the definition of lesson B includes references to A objects and/or A functions we must do the following in their respective .h files:

// A.h file #include B.h // include the B.h file lesson B; // forward declaration of B lesson A {

};

// B.h file #include A.h // include the A.h file lesson A; // forward declaration of A lesson B {

};

lesson Specifics

MyArray Template lesson

This is a safe, partially filled dynamic array template lesson that must be declared and defined in a single MyArray.h file (no MyArray.cpp file).

All functions of this lesson should handle any possible errors that may occur when interacting with an array. For example, a constructor should not attempt to create an array of a negative size.

data members:
a) data – dynamic array of type T

plus any other necessary array management variables
constructors:
a) default – create an empty array of capacity 10 b) single parameter – create an array of a specified capacity

functions:
a) getSize – return the number of elements in the array b) grow – private grow function (capacity*2)+ c) getIndex – given a value, return the position or -1 if not found. d) push_back – add element to the end of the array e) erase – remove the element at the specified index f) [] – overloaded [] operator: accept an index as input, return the element if it exists

the big three
(^)

Instructor lesson

data members: a) name – full name of the Instructor (with title) b) department – name of the Instructors department b) courses – MyArray object which stores course object pointers
constructors: a) default – create an anonymous Instructor (set name to Staff) b) single parameter – create an Instructor with name c) dual parameter – create an Instructor with name and department
functions: a) getName – accessor for name b) setName – mutator for name c) getDepartment – accessor for department d) setDepartment – mutator for department d) addCourse – add a specified Course (if not already added), update the Course object to reflect the change e) dropCourse – remove a specified Course (if teaching course) update the Course object to reflect the change f) display – displays the Instructor name, department and list of Courses
you lesson

data members: a) name – full name of the you b) courses – MyArray object which stores Course object pointers
constructors: a) default – create an anonymous you b) single parameter – create a you with a specified name
functions: a) getName – accessor for name b) setName – mutator for name d) addCourse – add a specified Course (if not already added), update the Course object to reflect the change e) dropCourse – remove a specified Course (if enrolled in course) update the Course object to reflect the change f) display – display the you name and a list of courses, use the overloaded [] operator from MyArray g) << – overloaded << operator displays the you name
Course lesson

data members: a) name – Course number/section b) instructor – Instructor object pointer b) yous – MyArray object which stores you object pointers
constructors: a) default – create an anonymous Instructor b) dual parameter – create a course with a name and Instructor
functions: a) getName – accessor for name b) setName – mutator for name c) getInstructor – accessor for Instructor, return Instructor object d) setInstructor – setter for Instructor, accept Instructor object e) addyou – add a specified you (if not already enrolled) update the you object to reflect the change f) dropyou – remove a specified you (if enrolled) update the you object to reflect the change g) dropInstructor – replace current Instructor with Staff, use the default Instructor constructor update the Instructor object to reflect the change g) display – display the Instructor name, display a list of yous, use the overloaded << operator from you

在线提交订单