Microsoft Word - assignment3.docx TCC CSCI 2843 Assignment 3 100 Points Due by Class 7 1) In this assignment, you will be designing and writing four classes. One of the classes will be the composite...

1 answer below »
Assignment 2 is done, i provided the source code for the main and header file as the assignments all build off the previous. Can you help?


Microsoft Word - assignment3.docx TCC CSCI 2843 Assignment 3 100 Points Due by Class 7 1) In this assignment, you will be designing and writing four classes. One of the classes will be the composite class with three members whose types are of the other three classes. 2) Each class should include a "reasonable" set of constructors to initialize their members. The composite class' constructor should take in enough information to initialize its members using their constructors in turn (in the initialization list, of course). 3) Each class will provide a public member function named output with the following signature: void output(std::ostream& s) const; The composite class' output function should be written in terms of calls to its members' output functions. 4) Overload the stream insertion operator (operator<) only="" for="" the="" composite="" class="" that="" simply="" calls="" the="" output="" function="" on="" the="" composite="" object.="" this="" can="" be,="" but="" does="" not="" necessarily="" have="" to="" be="" a="" friend.="" 5)="" each="" of="" the="" three="" member's="" classes="" must="" provide="" a="" function="" (of="" your="" own="" choosing)="" that="" "exercises"="" the="" functionality="" of="" the="" class.="" this="" exercise="" should="" involve="" some="" output="" to="" verify="" that="" the="" function="" was="" invoked,="" but="" can="" also="" manipulate="" the="" class'="" members="" in="" some="" fashion="" according="" to="" the="" design="" of="" the="" class.="" 6)="" the="" composite="" class="" must="" provide="" a="" single="" function="" that="" exercises="" its="" members="" by="" calling="" their="" functions="" that="" you="" supplied="" in="" (5)="" above.="" this="" is="" the="" delegation="" of="" the="" composite="" class="" to="" its="" individual="" members.="" 7)="" write="" a="" main="" function="" that="" instantiates="" an="" object="" of="" the="" composite="" type.="" after="" instantiation,="" output="" the="" object="" to="" cout.="" 8)="" invoke="" the="" composite="" class="" function="" you="" defined="" in="" (6)="" that="" will="" exercise="" all="" of="" its="" members="" as="" specified="" in="" (5).="" 9)="" place="" all="" classes="" in="" their="" own="" headers,="" protecting="" against="" multiple="" inclusion,="" and="" in="" a="" namespace="" of="" your="" own="" choosing.="" please="" turn="" in="" all="" source="" (and="" nothing="" but="" the="" source)="" on="" blackboard.="" assignment="" 4.pdf="" tcc="" csci="" 2843="" assignment="" 4="" 100="" points="" due="" by="" class="" 9="" 1.="" in="" this="" assignment,="" you="" will="" be="" using="" inheritance="" and="" polymorphism="" to="" implement="" a="" similar="" structure="" to="" the="" drawing/shape="" example="" in="" the="" lecture.="" for="" this,="" you="" will="" need="" to="" design="" and="" write="" a="" base="" class="" and="" three="" derived="" classes="" that="" inherit="" from="" the="" base="" (similar="" to="" the="" shape="" class="" and="" the="" derived="" shape="" classes).="" you="" will="" also="" need="" a="" “manager”="" class="" that="" will="" hold="" a="" (fixed)="" array="" of="" pointers="" to="" your="" base="" type="" (similar="" to="" the="" drawing="" class="" from="" the="" notes).="" 2.="" the="" base="" class="" may="" or="" may="" not="" have="" any="" member="" variables="" itself,="" depending="" on="" your="" design.="" the="" derived="" classes="" should="" have="" at="" least="" one="" member="" each="" to="" describe="" the="" structure/intent="" of="" that="" class.="" 3.="" you="" will="" provide="" one="" virtual="" function="" in="" the="" base="" class="" that="" each="" derived="" class="" will="" override.="" the="" base="" class’="" virtual="" function="" should="" be="" pure="" virtual="" (a.k.a.="" abstract)="" unless="" the="" base="" does="" indeed="" have="" an="" implementation.="" each="" derived="" type’s="" override="" of="" the="" virtual="" function="" should="" cause="" some="" output="" to="" std::cout="" to="" indicate="" that="" it="" was="" invoked.="" 4.="" each="" class="" should="" include="" a="" full="" set="" of="" constructors="" to="" initialize="" their="" member(s)="" as="" well="" as="" the="" base="" class.="" each="" derived="" class="" should="" call="" the="" base="" class’="" constructor="" in="" their="" initialization="" lists="" if="" needed.="" 5.="" your="" “manager”="" class="" will="" have="" an="" array="" of="" pointers="" to="" the="" base="" type="" that="" it="" manages="" and="" a="" method="" to="" add="" objects="" (by="" pointer-to-base)="" into="" the="" array="" and="" track="" how="" many="" items="" have="" been="" added.="" 6.="" include="" a="" function="" in="" the="" manager="" class="" that="" will="" loop="" through="" all="" of="" the="" objects="" in="" the="" array="" and="" invoke="" the="" virtual="" function="" for="" each="" element="" (just="" like="" drawing::draw="" looped="" through="" all="" of="" its="" shapes).="" 7.="" in="" your="" main="" function,="" instantiate="" a="" “manager”="" object.="" 8.="" add="" several="" objects="" of="" your="" types="" to="" the="" manager="" object.="" these="" objects="" will="" have="" to="" be="" created="" dynamically="" (with="" new)="" and="" passed="" into="" the="" function="" you="" made="" in="" (5)="" that="" will="" add="" the="" objects="" to="" the="" array.="" 9.="" call="" the="" manager="" object’s="" function="" from="" (6)="" that="" will="" loop="" through="" all="" objects="" you="" just="" added.="" 10.="" make="" sure="" that="" the="" manager’s="" constructor="" cleans="" up="" all="" of="" its="" objects="" when="" the="" manager="" object="" goes="" out="" of="" scope.="" 11.="" place="" all="" classes="" in="" their="" own="" headers="" (protecting="" against="" multiple="" inclusion)="" and="" in="" a="" namespace="" of="" your="" own="" choosing,="" using="" separate="" .cpp="" files="" for="" implementation="" if="" you="" choose.="" please="" turn="" in="" all="" source="" (and="" nothing="" but="" the="" source)="" on="" blackboard.="" circle.h="" #if="" !defined="" assignment_4_circle_header="" #define="" assignment_4_circle_header="" #pragma="" once="" #include=""> #include "shape.h" namespace graphics { class circle : public shape { public: void draw() override { std::cout < "drawing="" a="" circle\n";="" }="" };="" }="" #endif="" drawing.h="" #if="" !defined="" assignment_4_drawing_header="" #define="" assignment_4_drawing_header="" #pragma="" once="" #include=""> #include "shape.h" namespace graphics { class drawing { private: static const size_t max_shapes = 10; shape* shapes[max_shapes]; size_t num_shapes; public: drawing() : num_shapes{0u} { } bool add(shape* s) { if (num_shapes >= max_shapes) { return false; } shapes[num_shapes++] = s; return true; } void draw() { for (size_t i = 0u; i < num_shapes;="" ++i)="" {="" shapes[i]-="">draw(); } } size_t size() const { return num_shapes; } ~drawing() { for (size_t i = 0u; i < num_shapes;="" ++i)="" {="" delete="" shapes[i];="" }="" }="" };="" }="" #endif="" line.h="" #if="" !defined="" assignment_4_line_header="" #define="" assignment_4_line_header="" #pragma="" once="" #include=""> #include "shape.h" namespace graphics { class line : public shape { public: void draw() override { std::cout < "drawing="" a="" line\n";="" }="" };="" }="" #endif="" main.cpp="" #include="" "line.h"="" #include="" "circle.h"="" #include="" "rectangle.h"="" #include="" "drawing.h"="" int="" main()="" {="" graphics::drawing="" drawing;="" drawing.add(new="" graphics::line{});="" drawing.add(new="" graphics::circle{});="" drawing.add(new="" graphics::rectangle{});="" drawing.add(new="" graphics::circle{});="" drawing.add(new="" graphics::rectangle{});="" drawing.add(new="" graphics::line{});="" drawing.draw();="" return="" 0;="" }="" rectangle.h="" #if="" !defined="" assignment_4_rectangle_header="" #define="" assignment_4_rectangle_header="" #pragma="" once="" #include=""> #include "shape.h" namespace graphics { class rectangle : public shape { public: void draw() override { std::cout < "drawing="" a="" rectangle\n";="" }="" };="" }="" #endif="" shape.h="" #if="" !defined="" assignment_4_shape_header="" #define="" assignment_4_shape_header="" #pragma="" once="" #include=""> namespace graphics { class shape { public: virtual void draw() = 0; }; } #endif Assignment 5.pdf TCC CSCI 2843 Assignment 5 100 Points Due by class 11 1) For this assignment, fill out the following class: class employee { private: std::string first_name; std::string last_name; float monthly_pay; public: . . . }; You should provide any and all required constructors, access functions, and the operator<. 2)="" write="" a="" main="" function="" that="" opens="" a="" std::ifstream="" on="" the="" input="" file,="" "employee.dat"="" and="" a="" std::ofstream="" on="" an="" output="" file,="" "update.dat".="" if="" either="" stream="" cannot="" be="" opened,="" throw="" an="" exception="" and="" exit="" (hopefully="" with="" a="" useful="" diagnostic="" message).="" the="" file="" format="" is="" line-oriented="" and="" comma-delimited="" in="" the="" following="" format:="" last_name="" comma="" first_name="" comma="" monthly_pay="" newline="" 4)="" write="" a="" loop="" that,="" for="" each="" line="" in="" the="" file,="" reads="" from="" the="" std::ifstream="" and="" creates="" an="" employee="" object="" (i.e.="" first="" name,="" last="" name,="" and="" pay).="" on="" detecting="" end-of-file,="" exit="" the="" loop="" and="" end="" the="" program.="" if="" there="" is="" an="" error="" reading="" the="" information,="" throw="" an="" exception="" and="" exit="" the="" program.="" for="" each="" employee="" read,="" increment="" their="" monthly_pay="" by="" $50.00="" (everybody="" gets="" a="" raise).="" 5)="" while="" in="" the="" loop,="" after="" they="" get="" their="" raise,="" output="" each="" employee="" to="" std::cout="" and="" to="" the="" output="" file="" using="" the=""><. use the given file, employee.dat, for example input, but you should try some exceptional cases to make sure your code can detect and properly handle them. note - do not store the employee information – this is just an exercise in i/o – we will store objects that we have read in a later assignment. once the employee has been output, just let it go out of scope. 6) for all exceptions, make sure an error message detailing the cause of the exception is printed to the console before exiting the program. any further information (i.e. file and line number of exception) is purely optional. employee.dat horowitz,jake,1200.24 flabitz,bubba,1712.38 blackwell,sharon,1872.93 molerat,rufus,501.00 goodall,jane,1567.43 sommerset,william,1359.57 van helsing,marcus,1675.21 welfirth,bula,1903.83 poling,kerri,1243.32 lee,aswari kalim,1839.42 lisa,mona,2409.48 lisbon,frieda,1543.70 hatcher,gary,1220.13 use="" the="" given="" file,="" employee.dat,="" for="" example="" input,="" but="" you="" should="" try="" some="" exceptional="" cases="" to="" make="" sure="" your="" code="" can="" detect="" and="" properly="" handle="" them.="" note="" -="" do="" not="" store="" the="" employee="" information="" –="" this="" is="" just="" an="" exercise="" in="" i/o="" –="" we="" will="" store="" objects="" that="" we="" have="" read="" in="" a="" later="" assignment.="" once="" the="" employee="" has="" been="" output,="" just="" let="" it="" go="" out="" of="" scope.="" 6)="" for="" all="" exceptions,="" make="" sure="" an="" error="" message="" detailing="" the="" cause="" of="" the="" exception="" is="" printed="" to="" the="" console="" before="" exiting="" the="" program.="" any="" further="" information="" (i.e.="" file="" and="" line="" number="" of="" exception)="" is="" purely="" optional.="" employee.dat="" horowitz,jake,1200.24="" flabitz,bubba,1712.38="" blackwell,sharon,1872.93="" molerat,rufus,501.00="" goodall,jane,1567.43="" sommerset,william,1359.57="" van="" helsing,marcus,1675.21="" welfirth,bula,1903.83="" poling,kerri,1243.32="" lee,aswari="" kalim,1839.42="" lisa,mona,2409.48="" lisbon,frieda,1543.70="">
Answered Same DayMar 26, 2021

Answer To: Microsoft Word - assignment3.docx TCC CSCI 2843 Assignment 3 100 Points Due by Class 7 1) In this...

Meenakshi answered on Mar 28 2021
140 Votes
New folder (2)/Assignment 5.docx
Assignment 5
File handling using ofstream and ifstream
In this
assignment we design and develop a program for emp record .
Emp class having three private varirable
First name ,last name and montly pay
We define three public function
Get()
Getrecord()
Updaterecord()
Friend function << for display the record
We define two function
Insert()
The insert function is store the information into emp.dat
Displayrecord()
This function show the record and every display of the record monthly pay +50 and store each employee information store into update file
New folder (2)/Assignment5.cpp
New folder...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here