SlideShare a Scribd company logo
1 of 23
Q2/dayOfYear.cppQ2/dayOfYear.cpp/*
Name:
Copyright:
Author:
Date: 17/02/09 15:26
Description:
*/
#include"dayOfYear.h"
DayOfYear::DayOfYear():day(1),month(1),year(2009)
{
/* day =1;
month =1;
year =2009;
*/
}
DayOfYear::DayOfYear(int new_day,int new_month,int new_ye
ar)
{
day =new_day;
month =new_month;
year =new_year;
}
voidDayOfYear::output()const
{
cout <<"("<< day <<" ,"<< month <<" "<< year <<")"<<endl;
}
intDayOfYear::get_day()
{
return day;
}
intDayOfYear::get_month()
{
return month;
}
intDayOfYear::get_year()
{
return year;
}
voidDayOfYear::set_day(int new_day)
{
day = new_day;
}
bool equal(DayOfYear date1,DayOfYear date2)
{
if((date1.day == date2.day)&&(date1.month==date2.month)&&(
date1.year == date2.year))
returntrue;
else
returnfalse;
}
Q2/dayOfYear.h
#ifndef _DAYOFYEAR_H
#define _DAYOFYEAR_H
#include <iostream>
using namespace std;
class DayOfYear{
public:
friend bool equal(DayOfYear date1, DayOfYear
date2);//a friend function that compares two objects
//yes: if date1 is
the same as date2; no: otherwise
DayOfYear();//default constructor: 1/1/2009
DayOfYear(int new_day, int new_month, int
new_year);//
void output() const; //
int get_day(); // return the value of "day"
int get_month();
int get_year();
void set_DayOfYear(int new_day, int new_month, int
new_year); //new_day-->day, new_month->month, new_year--
>year
void set_day(int new_day); // day-->new_day
void set_month(int new_month);
void set_year(int new_year);
private:
int day;
int month; //int --> char *
int year;
};
#endif //
Q2/person.cppQ2/person.cpp/*
Name: person.cpp
Copyright:
Author:
Date: 22/02/09 14:35
Description: declaration of a new class DayOfYear
*/
#include"person.h"
Person::~Person()
{
if( emails != NULL ){
delete[] emails;
emails = NULL;
}
}
Person::Person()
{
id =-1;
name ="NA";
//birthday = DayOfYear( 1,1, 2000);
emails = NULL;
numEmails =0;
}
Person::Person(int new_id, string new_name,DayOfYear date)
{
id = new_id;
name = new_name;
//birthday = date;
emails=NULL;
numEmails=0;
}
/**/
Person::Person(constPerson& someone)
{
id = someone.id;
name = someone.name;
birthday = someone.birthday;
numEmails = someone.numEmails;
//allocate space to *emails if numEmails>0
if(numEmails ==0)
emails = NULL;
else{
emails =new string [numEmails];
for(int i=0;i<numEmails; i++)
emails[ i ]= someone.emails[ i ];
}
}
/**/
/**/
voidPerson::operator=(constPerson& rhs)
{
id = rhs.id;
name = rhs.name;
birthday = rhs.birthday;
//allocate space to *emails if needed
if(numEmails >0)
delete[] emails;//release the old memory
numEmails = rhs.numEmails;
emails =new string [numEmails];
for(int i=0;i<numEmails; i++)
emails[ i ]= rhs.emails[ i ];
}
/**/
voidPerson::output()const
{
// id = 200;
cout <<"--------------------------n";
cout <<" id="<<(*this).id <<" name="<<this-
>name <<" birthday=";
birthday.output();
for(int i=0; i<numEmails; i++)
cout <<"email-#"<< i <<": "<< emails[i];
cout <<"n--------------------------nn";
}
intPerson::get_id()const
{
return id;
}
string Person::get_name()const
{
return name;
}
constDayOfYearPerson::get_birthday()const
{
return birthday;
}
voidPerson::set_id(int new_id)
{
id = new_id;
}
voidPerson::set_name(string new_name)
{
name = new_name;
}
voidPerson::set_birthday(DayOfYear date)
{
birthday = date;
}
string Person::getEmail(int i)const
{
if(i>=0&& i<numEmails)
return emails[i];
else
return"NA";
}
voidPerson::add_email( string the_email)
{
//case 1: emails list is empty
if( numEmails ==0){
emails =new string[1];
//verification
emails[0]= the_email;
}
else{//case 2: expand the list
string *tmp_emails=new string [numEmails];
for(int i=0; i<numEmails; i++)//save the emails
tmp_emails[i]= emails[ i ];
delete[] emails;
emails =new string [numEmails+1];//expand the list by o
ne
//verify the above allocation
for(int i=0; i<numEmails; i++)
emails[ i ]= tmp_emails[ i ];//copy the existing emails
emails[ numEmails ]= the_email;// add the new email
delete[] tmp_emails;
}
numEmails +=1;
}
intPerson::get_num_emails()const
{
return numEmails;
}
void print(constPerson& someone)
{
cout <<"****"<<someone.get_id()<<" "<< someone.get_nam
e()<<endl;
}
//perform a sequential search on the studentList
bool searchStudent(Person*studentList,int num_students,int key
)
{
for(int i=0; i<num_students; i++){
if( studentList[ i ].get_id()== key )//found
returntrue;
}//for (i)
returnfalse;//none of the students has ID=key
}
bool sameID(constPerson& person1,constPerson& person2)
{
return(person1.get_id()== person2.get_id());
}
bool equalID(constPerson& person1,constPerson& person2)
{
return(person1.id == person2.id);
}
Q2/person.h
//person.h
#ifndef _PERSON_H
#define _PERSON_H
#include <iostream>
#include <string>
#include "dayOfYear.h"
using namespace std;
class Person{
public:
//equalID() returns true:have the same ID; false:
otherwise
friend bool equalID(const Person & person1, const
Person &Person2);//
~Person(); //destructor: to release any memory that has
been allocated to the object
Person(); //default constructor: id=-1, name="NA",
birthday="1/1/2000"
Person( int new_id, string new_name, DayOfYear date);
//constructor that initializes
//id to new_id, name to new_name, and
birthday to date
Person(const Person & someone); //copy constructor:
construct a new object as a copy of "someone"
void operator= (const Person &rhs); //assign the object
on the right-hand-side to the left-hand-side
virtual void output() const; //print out a person's info.
int get_id() const; //return the id of a Person object
string get_name() const; //return the name of a Person
object
const DayOfYear get_birthday() const; //return the
birthday of a Person object
string getEmail( int i) const; //return the i-th email if
exists; o.w: return "NA"
void set_id(int new_id); //change a person's id to
new_id
void set_name(string new_name); // change a person's
name to new_name
void set_birthday(DayOfYear new_Date); //change a
person's birthday to new_date
void add_email( string the_email); //add the_email to
the list
int get_num_emails() const;
private:
int id;
string name;
DayOfYear birthday;
string *emails; //list of email addresses
int numEmails;
};
void print( const Person& someone); //print out a person's id
and name
bool sameID(const Person& person1, const Person&
person2);//true:have the same ID; false: otherwise
//search whether there exists a student on the studentList with
id=key
bool searchStudent( Person *studentList, int num_students, int
key);
#endif
Q2/personnel.cppQ2/personnel.cpp/*
Name: personnel.cpp
Copyright:
Author:
Date: 22/02/09 15:02
Description: manage a personnel database that currently consis
ts of one employee Mary
*/
#include"dayOfYear.h"
#include"person.h"
#include"student.h"
int main()
{
DayOfYear date(20,7,1985);
Person mary_p(101,"Mary", date);
Student mary_s(101,"Mary", date,1), mary_c;
// Person & mary_p = mary_s;
Person& person1 = mary_s;
mary_s.output();//student verion
person1.output();
/*
mary_p.output();
mary_s.Person::output();//person version
print( mary_s );
mary_s.add_email("[email protected]");
mary_s.set_num_grades(2);
mary_s.set_grade(1, 98.00);
mary_s.set_grade(2, 100.00);
mary_c = mary_s;
cout << mary_s;
cout << mary_c;
*/
//mary_clone.set_id(202);
// print(mary_clone);
//mary_clone.output();
// mary = mary_clone;
// mary.output();
//sameID(mary, mary_clone);
// equalID(mary, mary_clone);
/**the code below create a dynamic array of Person
***
//1 & 2:
Person *students213 = NULL; //
int num = 200; //size of the dynamic array *students213
//3. allocate memory to students213
students213 = new Person [ num ];
//4. verify
if (students213 == NULL ){
cerr << "Memory allocation failure.n";
exit( -1 );
}
//5: use
for (int i=0; i<num; i++){
students213[ i ].set_id( i + 100);
students213[ i ].output();
}
//search based on id
cout << "Is there a student with ID=207? ";
if (searchStudent( students213, num, 207) )
cout << " Yes."<<endl;
else
cout << " No. "<<endl;
cout << "Is there a student with ID=507? ";
if (searchStudent( students213, num, 507) )
cout << " Yes."<<endl;
else
cout << " No. "<<endl;
//6&7: release the memory
delete [] students213;
students213 = NULL;
*****
**end of the dynamic array students213
**************************************/
return0;
}
Q2/student.cppQ2/student.cpp//File name--
student.cpp: implementation file for the Student class
#include"student.h"
//#include "dayOfYear.h"
//destructor
Student::~Student()
{
if(grades != NULL ){
delete[] grades;
}
}
//default constructor
Student::Student():Person()
{
//call the constructor of the base class to initialize the inherited
members
level =1;//freshmen
num_grades =0;
grades = NULL;
}
//a second constructor
Student::Student(int new_id, string new_name,DayOfYear date,i
nt lvl):Person(new_id, new_name, date),level(lvl),num_grades(0
),grades(NULL)
{
//call the corresponding constructor in the
//base class to initialize the inherited members
/* level = lvl;
num_grades = 0;
grades = NULL;
*/
}
//copy constructor
Student::Student(constStudent& std):Person(std)//call the copy
constructor of the base class
{
level = std.level;
num_grades = std.num_grades;
if(num_grades <=0)
grades = NULL;
else{//allocate space to *grades and copy the grades from std
(*this).grades =newdouble[ num_grades ];
if(grades == NULL ){
cerr<<"Student:Student(const Student &): Memory alloc
ation errorn";
exit(-1);
}
for(int i=0; i<num_grades; i++)
grades[ i ]= std.grades[ i ];
}
}
voidStudent::operator=(constStudent& rhs)
{
(*this).Person::operator=(rhs);
level = rhs.level;
if(num_grades != rhs.num_grades){
delete[] grades;
num_grades = rhs.num_grades;
grades =newdouble[ num_grades ];
if(grades == NULL){
cerr<<"Student:operator=(const Student &): Memory all
ocation errorn";
exit(-1);
}
for(int i=0; i<num_grades; i++)
grades[ i ]= rhs.grades[ i ];
}
}
intStudent::get_level()const
{
return level;
}
intStudent::get_num_grades()const
{
return num_grades;
}
doubleStudent::get_grade(int i)const
{
if(i<1|| i>num_grades)
return-1.0;//non-existent grade
else
return grades[ i-1];
}
voidStudent::set_level(int lvl)
{
level = lvl;
}
voidStudent::set_num_grades(int num)
{
num_grades = num;
if(num >0){
grades =newdouble[ num ];
if(grades == NULL ){
cerr<<"Student:set_num_grades(int ): Memory allocation
errorn";
exit(-1);
}
for(int i=0; i<num; i++)
grades[ i ]=0;
}
}
voidStudent::set_grade(int i,double grd)
{
if(i>=1&& i<=num_grades)
grades[ i-1]= grd;
}
ostream&operator<<(ostream& out,constStudent& std)
{
DayOfYear bday;
bday = std.get_birthday();
out <<"------------------------------n";
out <<"id="<< std.get_id()<<endl;
out <<"name="<< std.get_name()<< endl;
out <<"birthday="<< bday.get_day();
out <<"-"<< bday.get_month();
out <<"-"<< bday.get_year()<< endl;
out <<"#emails="<<std.get_num_emails()<<endl;
out <<" 1st email="<< std.getEmail(0)<<endl;
out <<"level="<<std.level<<endl;
out <<"#grades="<< std.num_grades <<endl;
for(int i=1; i<=std.num_grades; i++)
out <<"grade["<< i <<"]="<< std.grades[i-1]<<" ";
out <<endl;
out <<"------------------------------n";
return out;
}
voidStudent::output()const
{
DayOfYear bday;
bday = get_birthday();
cout <<"------------------------------n";
cout <<"id="<< get_id()<<endl;
cout <<"name="<< get_name()<< endl;//private-is-
private rule
cout <<"birthday="<< bday.get_day();
cout <<"-"<< bday.get_month();
cout <<"-"<< bday.get_year()<< endl;
cout <<"#emails="<<get_num_emails()<<endl;
cout <<" 1st email="<< getEmail(0)<<endl;
cout <<"level="<<level<<endl;
cout <<"#grades="<< num_grades <<endl;
for(int i=1; i<=num_grades; i++)
cout <<"grade["<< i <<"]="<< grades[i-1]<<" ";
cout <<endl;
cout <<"------------------------------n";
}
Q2/student.h
//File name--student.h: declare Student as a derived class of
Person
#ifndef _STUDENT_H
#define _STUDENT_H
#include "person.h"
class Student:public Person
{
public:
~Student(); //destructor
Student(); //default: 1->level, 0->num_grades, NULL-
>grades
Student(int new_id, string new_name, DayOfYear date,
int lvl ); //lvl->level, 0->num_grades, NULL->grades
Student(const Student& std); //copy constructor: std --
>*this
void operator=(const Student& rhs); //rhs --> *this
int get_level() const; //return level
int get_num_grades() const; //return num_grades
double get_grade(int i) const; //return grades[i]
void set_level(int lvl); //lvl-->level
void set_num_grades( int num); //num->num_grades,
allocate memory to *grades
void set_grade(int i, double grd); //grd --> grades[i]
friend ostream & operator <<( ostream & out, const
Student& std);
virtual void output() const; //print out a student's info.
private:
int level; //1-4: freshmen, sophomore, junior and senior
int num_grades;
double *grades;
};
#endif //_STUDENT_H
Q1/9.cpp
#include <iostream>
#include "figure.h"
#include "rectangle.h"
#include "triangle.h"
using std::cout;
int main()
{
Triangle tri;
tri.draw();
cout << "nDerived class Triangle object calling" << "
center().n";
tri.center();
Rectangle rect;
rect.draw();
cout << "nDerived class Rectangle object calling" << "
center().n";
rect.center();
return 0;
}
Each topic must have 150+ words
Topic 1:
Cherie is an accountant for a large advertising agency. After
receiving notice of a prospective, large account, she thinks of a
creative advertising campaign and tells her idea to Charles, her
manager. Charles shoots down her idea and reminds her that her
job is accounting. Several days later, the design team visits
Charles and asks him for more details on his brilliant campaign
idea. Cherie realizes that the campaign being discussed is her
idea.
What does this outcome indicate about the communication
climate and power holding in the agency? If you were Cherie,
would you approach Charles about stealing your idea, or would
you show support for your manager? Why?
Topic 2:
When it comes to coworkers, why are strong interpersonal
relationships important in business?
How do you build and maintain those relationships while
keeping professionalism at the forefront?
What are some challenges you face in doing so?
What are the key factors upon which coworker relationships are
usually based? Tell us about your experiences.

More Related Content

Similar to Q2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docx

INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docxINTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
normanibarber20063
 
In this assignment, you will continue working on your application..docx
In this assignment, you will continue working on your application..docxIn this assignment, you will continue working on your application..docx
In this assignment, you will continue working on your application..docx
jaggernaoma
 
public class Person { private String name; private int age;.pdf
public class Person { private String name; private int age;.pdfpublic class Person { private String name; private int age;.pdf
public class Person { private String name; private int age;.pdf
arjuncp10
 
please help with java questionsJAVA CODEplease check my code and.pdf
please help with java questionsJAVA CODEplease check my code and.pdfplease help with java questionsJAVA CODEplease check my code and.pdf
please help with java questionsJAVA CODEplease check my code and.pdf
arishmarketing21
 
Complete DB code following the instructions Implement the D.pdf
Complete DB code following the instructions Implement the D.pdfComplete DB code following the instructions Implement the D.pdf
Complete DB code following the instructions Implement the D.pdf
access2future1
 
#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf
annucommunication1
 
So here is the code from the previous assignment that we need to ext.pdf
So here is the code from the previous assignment that we need to ext.pdfSo here is the code from the previous assignment that we need to ext.pdf
So here is the code from the previous assignment that we need to ext.pdf
leolight2
 
Consider the classes below- Here is the code for the ParentChildRelati.pdf
Consider the classes below- Here is the code for the ParentChildRelati.pdfConsider the classes below- Here is the code for the ParentChildRelati.pdf
Consider the classes below- Here is the code for the ParentChildRelati.pdf
21stcenturyjammu21
 
Use the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdfUse the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdf
sales87
 
I keep on get a redefinition error and an undefined error.Customer.pdf
I keep on get a redefinition error and an undefined error.Customer.pdfI keep on get a redefinition error and an undefined error.Customer.pdf
I keep on get a redefinition error and an undefined error.Customer.pdf
herminaherman
 
So Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdfSo Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdf
arihantgiftgallery
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdf
aplolomedicalstoremr
 
CounterTest.javaimport static org.junit.Assert.;import org.jun.pdf
CounterTest.javaimport static org.junit.Assert.;import org.jun.pdfCounterTest.javaimport static org.junit.Assert.;import org.jun.pdf
CounterTest.javaimport static org.junit.Assert.;import org.jun.pdf
deepua8
 
SinglyLinkedListPseudoCode.txtCLASS SinglyLinkedList se.docx
SinglyLinkedListPseudoCode.txtCLASS SinglyLinkedList    se.docxSinglyLinkedListPseudoCode.txtCLASS SinglyLinkedList    se.docx
SinglyLinkedListPseudoCode.txtCLASS SinglyLinkedList se.docx
jennifer822
 
Date class that represents a date consisting of a year, month, and a.pdf
Date class that represents a date consisting of a year, month, and a.pdfDate class that represents a date consisting of a year, month, and a.pdf
Date class that represents a date consisting of a year, month, and a.pdf
anilgoelslg
 

Similar to Q2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docx (20)

INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docxINTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
INTERMIDIATE PROGRAMMINGCMPSC 122LAB 9 INHERITANCE AND POLYMO.docx
 
Kotlin Data Model
Kotlin Data ModelKotlin Data Model
Kotlin Data Model
 
C++ L07-Struct
C++ L07-StructC++ L07-Struct
C++ L07-Struct
 
In this assignment, you will continue working on your application..docx
In this assignment, you will continue working on your application..docxIn this assignment, you will continue working on your application..docx
In this assignment, you will continue working on your application..docx
 
public class Person { private String name; private int age;.pdf
public class Person { private String name; private int age;.pdfpublic class Person { private String name; private int age;.pdf
public class Person { private String name; private int age;.pdf
 
please help with java questionsJAVA CODEplease check my code and.pdf
please help with java questionsJAVA CODEplease check my code and.pdfplease help with java questionsJAVA CODEplease check my code and.pdf
please help with java questionsJAVA CODEplease check my code and.pdf
 
Complete DB code following the instructions Implement the D.pdf
Complete DB code following the instructions Implement the D.pdfComplete DB code following the instructions Implement the D.pdf
Complete DB code following the instructions Implement the D.pdf
 
#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf#include iostream #includeData.h #includePerson.h#in.pdf
#include iostream #includeData.h #includePerson.h#in.pdf
 
Introduction to ECMAScript 2015
Introduction to ECMAScript 2015Introduction to ECMAScript 2015
Introduction to ECMAScript 2015
 
So here is the code from the previous assignment that we need to ext.pdf
So here is the code from the previous assignment that we need to ext.pdfSo here is the code from the previous assignment that we need to ext.pdf
So here is the code from the previous assignment that we need to ext.pdf
 
Consider the classes below- Here is the code for the ParentChildRelati.pdf
Consider the classes below- Here is the code for the ParentChildRelati.pdfConsider the classes below- Here is the code for the ParentChildRelati.pdf
Consider the classes below- Here is the code for the ParentChildRelati.pdf
 
Use the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdfUse the code below from the previous assignment that we need to exte.pdf
Use the code below from the previous assignment that we need to exte.pdf
 
I keep on get a redefinition error and an undefined error.Customer.pdf
I keep on get a redefinition error and an undefined error.Customer.pdfI keep on get a redefinition error and an undefined error.Customer.pdf
I keep on get a redefinition error and an undefined error.Customer.pdf
 
So Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdfSo Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdf
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdf
 
CounterTest.javaimport static org.junit.Assert.;import org.jun.pdf
CounterTest.javaimport static org.junit.Assert.;import org.jun.pdfCounterTest.javaimport static org.junit.Assert.;import org.jun.pdf
CounterTest.javaimport static org.junit.Assert.;import org.jun.pdf
 
#include iostream #include iomanip needed for formatting .docx
#include iostream #include iomanip  needed for formatting .docx#include iostream #include iomanip  needed for formatting .docx
#include iostream #include iomanip needed for formatting .docx
 
SinglyLinkedListPseudoCode.txtCLASS SinglyLinkedList se.docx
SinglyLinkedListPseudoCode.txtCLASS SinglyLinkedList    se.docxSinglyLinkedListPseudoCode.txtCLASS SinglyLinkedList    se.docx
SinglyLinkedListPseudoCode.txtCLASS SinglyLinkedList se.docx
 
Date class that represents a date consisting of a year, month, and a.pdf
Date class that represents a date consisting of a year, month, and a.pdfDate class that represents a date consisting of a year, month, and a.pdf
Date class that represents a date consisting of a year, month, and a.pdf
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
 

More from amrit47

Apa format1-2 paragraphsreferences It is often said th.docx
Apa format1-2 paragraphsreferences It is often said th.docxApa format1-2 paragraphsreferences It is often said th.docx
Apa format1-2 paragraphsreferences It is often said th.docx
amrit47
 
APA Formatting AssignmentUse the information below to create.docx
APA Formatting AssignmentUse the information below to create.docxAPA Formatting AssignmentUse the information below to create.docx
APA Formatting AssignmentUse the information below to create.docx
amrit47
 
APA style300 words10 maximum plagiarism  Mrs. Smith was.docx
APA style300 words10 maximum plagiarism  Mrs. Smith was.docxAPA style300 words10 maximum plagiarism  Mrs. Smith was.docx
APA style300 words10 maximum plagiarism  Mrs. Smith was.docx
amrit47
 
APA General Format Summary APA (American Psychological.docx
APA General Format Summary APA (American Psychological.docxAPA General Format Summary APA (American Psychological.docx
APA General Format Summary APA (American Psychological.docx
amrit47
 
Appearance When I watched the video of myself, I felt that my b.docx
Appearance When I watched the video of myself, I felt that my b.docxAppearance When I watched the video of myself, I felt that my b.docx
Appearance When I watched the video of myself, I felt that my b.docx
amrit47
 
APA STYLE  follow this textbook answer should be summarize for t.docx
APA STYLE  follow this textbook answer should be summarize for t.docxAPA STYLE  follow this textbook answer should be summarize for t.docx
APA STYLE  follow this textbook answer should be summarize for t.docx
amrit47
 

More from amrit47 (20)

APA, The assignment require a contemporary approach addressing Race,.docx
APA, The assignment require a contemporary approach addressing Race,.docxAPA, The assignment require a contemporary approach addressing Race,.docx
APA, The assignment require a contemporary approach addressing Race,.docx
 
APA style and all questions answered ( no min page requirements) .docx
APA style and all questions answered ( no min page requirements) .docxAPA style and all questions answered ( no min page requirements) .docx
APA style and all questions answered ( no min page requirements) .docx
 
Apa format1-2 paragraphsreferences It is often said th.docx
Apa format1-2 paragraphsreferences It is often said th.docxApa format1-2 paragraphsreferences It is often said th.docx
Apa format1-2 paragraphsreferences It is often said th.docx
 
APA format2-3 pages, double-spaced1. Choose a speech to review. It.docx
APA format2-3 pages, double-spaced1. Choose a speech to review. It.docxAPA format2-3 pages, double-spaced1. Choose a speech to review. It.docx
APA format2-3 pages, double-spaced1. Choose a speech to review. It.docx
 
APA format  httpsapastyle.apa.orghttpsowl.purd.docx
APA format     httpsapastyle.apa.orghttpsowl.purd.docxAPA format     httpsapastyle.apa.orghttpsowl.purd.docx
APA format  httpsapastyle.apa.orghttpsowl.purd.docx
 
APA format2-3 pages, double-spaced1. Choose a speech to review. .docx
APA format2-3 pages, double-spaced1. Choose a speech to review. .docxAPA format2-3 pages, double-spaced1. Choose a speech to review. .docx
APA format2-3 pages, double-spaced1. Choose a speech to review. .docx
 
APA Formatting AssignmentUse the information below to create.docx
APA Formatting AssignmentUse the information below to create.docxAPA Formatting AssignmentUse the information below to create.docx
APA Formatting AssignmentUse the information below to create.docx
 
APA style300 words10 maximum plagiarism  Mrs. Smith was.docx
APA style300 words10 maximum plagiarism  Mrs. Smith was.docxAPA style300 words10 maximum plagiarism  Mrs. Smith was.docx
APA style300 words10 maximum plagiarism  Mrs. Smith was.docx
 
APA format1. What are the three most important takeawayslessons.docx
APA format1. What are the three most important takeawayslessons.docxAPA format1. What are the three most important takeawayslessons.docx
APA format1. What are the three most important takeawayslessons.docx
 
APA General Format Summary APA (American Psychological.docx
APA General Format Summary APA (American Psychological.docxAPA General Format Summary APA (American Psychological.docx
APA General Format Summary APA (American Psychological.docx
 
Appearance When I watched the video of myself, I felt that my b.docx
Appearance When I watched the video of myself, I felt that my b.docxAppearance When I watched the video of myself, I felt that my b.docx
Appearance When I watched the video of myself, I felt that my b.docx
 
apa format1-2 paragraphsreferencesFor this week’s .docx
apa format1-2 paragraphsreferencesFor this week’s .docxapa format1-2 paragraphsreferencesFor this week’s .docx
apa format1-2 paragraphsreferencesFor this week’s .docx
 
APA Format, with 2 references for each question and an assignment..docx
APA Format, with 2 references for each question and an assignment..docxAPA Format, with 2 references for each question and an assignment..docx
APA Format, with 2 references for each question and an assignment..docx
 
APA-formatted 8-10 page research paper which examines the potential .docx
APA-formatted 8-10 page research paper which examines the potential .docxAPA-formatted 8-10 page research paper which examines the potential .docx
APA-formatted 8-10 page research paper which examines the potential .docx
 
APA    STYLE 1.Define the terms multiple disabilities and .docx
APA    STYLE 1.Define the terms multiple disabilities and .docxAPA    STYLE 1.Define the terms multiple disabilities and .docx
APA    STYLE 1.Define the terms multiple disabilities and .docx
 
APA STYLE  follow this textbook answer should be summarize for t.docx
APA STYLE  follow this textbook answer should be summarize for t.docxAPA STYLE  follow this textbook answer should be summarize for t.docx
APA STYLE  follow this textbook answer should be summarize for t.docx
 
APA7Page length 3-4, including Title Page and Reference Pag.docx
APA7Page length 3-4, including Title Page and Reference Pag.docxAPA7Page length 3-4, including Title Page and Reference Pag.docx
APA7Page length 3-4, including Title Page and Reference Pag.docx
 
APA format, 2 pagesThree general sections 1. an article s.docx
APA format, 2 pagesThree general sections 1. an article s.docxAPA format, 2 pagesThree general sections 1. an article s.docx
APA format, 2 pagesThree general sections 1. an article s.docx
 
APA Style with minimum of 450 words, with annotations, quotation.docx
APA Style with minimum of 450 words, with annotations, quotation.docxAPA Style with minimum of 450 words, with annotations, quotation.docx
APA Style with minimum of 450 words, with annotations, quotation.docx
 
APA FORMAT1.  What are the three most important takeawayslesson.docx
APA FORMAT1.  What are the three most important takeawayslesson.docxAPA FORMAT1.  What are the three most important takeawayslesson.docx
APA FORMAT1.  What are the three most important takeawayslesson.docx
 

Recently uploaded

Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 

Recently uploaded (20)

Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 

Q2dayOfYear.cppQ2dayOfYear.cpp  Name   Copyright  .docx

  • 1. Q2/dayOfYear.cppQ2/dayOfYear.cpp/* Name: Copyright: Author: Date: 17/02/09 15:26 Description: */ #include"dayOfYear.h" DayOfYear::DayOfYear():day(1),month(1),year(2009) { /* day =1; month =1; year =2009; */ } DayOfYear::DayOfYear(int new_day,int new_month,int new_ye ar) { day =new_day; month =new_month; year =new_year; } voidDayOfYear::output()const { cout <<"("<< day <<" ,"<< month <<" "<< year <<")"<<endl; } intDayOfYear::get_day()
  • 2. { return day; } intDayOfYear::get_month() { return month; } intDayOfYear::get_year() { return year; } voidDayOfYear::set_day(int new_day) { day = new_day; } bool equal(DayOfYear date1,DayOfYear date2) { if((date1.day == date2.day)&&(date1.month==date2.month)&&( date1.year == date2.year)) returntrue; else returnfalse; } Q2/dayOfYear.h #ifndef _DAYOFYEAR_H #define _DAYOFYEAR_H
  • 3. #include <iostream> using namespace std; class DayOfYear{ public: friend bool equal(DayOfYear date1, DayOfYear date2);//a friend function that compares two objects //yes: if date1 is the same as date2; no: otherwise DayOfYear();//default constructor: 1/1/2009 DayOfYear(int new_day, int new_month, int new_year);// void output() const; // int get_day(); // return the value of "day" int get_month(); int get_year(); void set_DayOfYear(int new_day, int new_month, int new_year); //new_day-->day, new_month->month, new_year-- >year void set_day(int new_day); // day-->new_day void set_month(int new_month);
  • 4. void set_year(int new_year); private: int day; int month; //int --> char * int year; }; #endif // Q2/person.cppQ2/person.cpp/* Name: person.cpp Copyright: Author: Date: 22/02/09 14:35 Description: declaration of a new class DayOfYear */ #include"person.h" Person::~Person() { if( emails != NULL ){ delete[] emails; emails = NULL; } }
  • 5. Person::Person() { id =-1; name ="NA"; //birthday = DayOfYear( 1,1, 2000); emails = NULL; numEmails =0; } Person::Person(int new_id, string new_name,DayOfYear date) { id = new_id; name = new_name; //birthday = date; emails=NULL; numEmails=0; } /**/ Person::Person(constPerson& someone) { id = someone.id; name = someone.name; birthday = someone.birthday; numEmails = someone.numEmails; //allocate space to *emails if numEmails>0 if(numEmails ==0) emails = NULL; else{ emails =new string [numEmails]; for(int i=0;i<numEmails; i++) emails[ i ]= someone.emails[ i ]; } } /**/
  • 6. /**/ voidPerson::operator=(constPerson& rhs) { id = rhs.id; name = rhs.name; birthday = rhs.birthday; //allocate space to *emails if needed if(numEmails >0) delete[] emails;//release the old memory numEmails = rhs.numEmails; emails =new string [numEmails]; for(int i=0;i<numEmails; i++) emails[ i ]= rhs.emails[ i ]; } /**/ voidPerson::output()const { // id = 200; cout <<"--------------------------n"; cout <<" id="<<(*this).id <<" name="<<this- >name <<" birthday="; birthday.output(); for(int i=0; i<numEmails; i++) cout <<"email-#"<< i <<": "<< emails[i]; cout <<"n--------------------------nn"; } intPerson::get_id()const { return id; }
  • 7. string Person::get_name()const { return name; } constDayOfYearPerson::get_birthday()const { return birthday; } voidPerson::set_id(int new_id) { id = new_id; } voidPerson::set_name(string new_name) { name = new_name; } voidPerson::set_birthday(DayOfYear date) { birthday = date; } string Person::getEmail(int i)const { if(i>=0&& i<numEmails) return emails[i]; else return"NA"; } voidPerson::add_email( string the_email) {
  • 8. //case 1: emails list is empty if( numEmails ==0){ emails =new string[1]; //verification emails[0]= the_email; } else{//case 2: expand the list string *tmp_emails=new string [numEmails]; for(int i=0; i<numEmails; i++)//save the emails tmp_emails[i]= emails[ i ]; delete[] emails; emails =new string [numEmails+1];//expand the list by o ne //verify the above allocation for(int i=0; i<numEmails; i++) emails[ i ]= tmp_emails[ i ];//copy the existing emails emails[ numEmails ]= the_email;// add the new email delete[] tmp_emails; } numEmails +=1; } intPerson::get_num_emails()const { return numEmails; } void print(constPerson& someone) { cout <<"****"<<someone.get_id()<<" "<< someone.get_nam e()<<endl; } //perform a sequential search on the studentList
  • 9. bool searchStudent(Person*studentList,int num_students,int key ) { for(int i=0; i<num_students; i++){ if( studentList[ i ].get_id()== key )//found returntrue; }//for (i) returnfalse;//none of the students has ID=key } bool sameID(constPerson& person1,constPerson& person2) { return(person1.get_id()== person2.get_id()); } bool equalID(constPerson& person1,constPerson& person2) { return(person1.id == person2.id); } Q2/person.h //person.h #ifndef _PERSON_H #define _PERSON_H #include <iostream> #include <string> #include "dayOfYear.h"
  • 10. using namespace std; class Person{ public: //equalID() returns true:have the same ID; false: otherwise friend bool equalID(const Person & person1, const Person &Person2);// ~Person(); //destructor: to release any memory that has been allocated to the object Person(); //default constructor: id=-1, name="NA", birthday="1/1/2000" Person( int new_id, string new_name, DayOfYear date); //constructor that initializes //id to new_id, name to new_name, and birthday to date Person(const Person & someone); //copy constructor: construct a new object as a copy of "someone" void operator= (const Person &rhs); //assign the object on the right-hand-side to the left-hand-side virtual void output() const; //print out a person's info.
  • 11. int get_id() const; //return the id of a Person object string get_name() const; //return the name of a Person object const DayOfYear get_birthday() const; //return the birthday of a Person object string getEmail( int i) const; //return the i-th email if exists; o.w: return "NA" void set_id(int new_id); //change a person's id to new_id void set_name(string new_name); // change a person's name to new_name void set_birthday(DayOfYear new_Date); //change a person's birthday to new_date void add_email( string the_email); //add the_email to the list int get_num_emails() const; private: int id; string name; DayOfYear birthday; string *emails; //list of email addresses int numEmails;
  • 12. }; void print( const Person& someone); //print out a person's id and name bool sameID(const Person& person1, const Person& person2);//true:have the same ID; false: otherwise //search whether there exists a student on the studentList with id=key bool searchStudent( Person *studentList, int num_students, int key); #endif Q2/personnel.cppQ2/personnel.cpp/* Name: personnel.cpp Copyright: Author: Date: 22/02/09 15:02 Description: manage a personnel database that currently consis ts of one employee Mary */ #include"dayOfYear.h" #include"person.h" #include"student.h" int main() {
  • 13. DayOfYear date(20,7,1985); Person mary_p(101,"Mary", date); Student mary_s(101,"Mary", date,1), mary_c; // Person & mary_p = mary_s; Person& person1 = mary_s; mary_s.output();//student verion person1.output(); /* mary_p.output(); mary_s.Person::output();//person version print( mary_s ); mary_s.add_email("[email protected]"); mary_s.set_num_grades(2); mary_s.set_grade(1, 98.00); mary_s.set_grade(2, 100.00); mary_c = mary_s; cout << mary_s; cout << mary_c; */ //mary_clone.set_id(202); // print(mary_clone); //mary_clone.output(); // mary = mary_clone; // mary.output(); //sameID(mary, mary_clone); // equalID(mary, mary_clone);
  • 14. /**the code below create a dynamic array of Person *** //1 & 2: Person *students213 = NULL; // int num = 200; //size of the dynamic array *students213 //3. allocate memory to students213 students213 = new Person [ num ]; //4. verify if (students213 == NULL ){ cerr << "Memory allocation failure.n"; exit( -1 ); } //5: use for (int i=0; i<num; i++){ students213[ i ].set_id( i + 100); students213[ i ].output(); } //search based on id cout << "Is there a student with ID=207? "; if (searchStudent( students213, num, 207) ) cout << " Yes."<<endl; else cout << " No. "<<endl; cout << "Is there a student with ID=507? "; if (searchStudent( students213, num, 507) ) cout << " Yes."<<endl; else cout << " No. "<<endl; //6&7: release the memory delete [] students213; students213 = NULL;
  • 15. ***** **end of the dynamic array students213 **************************************/ return0; } Q2/student.cppQ2/student.cpp//File name-- student.cpp: implementation file for the Student class #include"student.h" //#include "dayOfYear.h" //destructor Student::~Student() { if(grades != NULL ){ delete[] grades; } } //default constructor Student::Student():Person() { //call the constructor of the base class to initialize the inherited members level =1;//freshmen num_grades =0; grades = NULL; } //a second constructor Student::Student(int new_id, string new_name,DayOfYear date,i nt lvl):Person(new_id, new_name, date),level(lvl),num_grades(0 ),grades(NULL) { //call the corresponding constructor in the
  • 16. //base class to initialize the inherited members /* level = lvl; num_grades = 0; grades = NULL; */ } //copy constructor Student::Student(constStudent& std):Person(std)//call the copy constructor of the base class { level = std.level; num_grades = std.num_grades; if(num_grades <=0) grades = NULL; else{//allocate space to *grades and copy the grades from std (*this).grades =newdouble[ num_grades ]; if(grades == NULL ){ cerr<<"Student:Student(const Student &): Memory alloc ation errorn"; exit(-1); } for(int i=0; i<num_grades; i++) grades[ i ]= std.grades[ i ]; } } voidStudent::operator=(constStudent& rhs) { (*this).Person::operator=(rhs); level = rhs.level; if(num_grades != rhs.num_grades){ delete[] grades; num_grades = rhs.num_grades; grades =newdouble[ num_grades ];
  • 17. if(grades == NULL){ cerr<<"Student:operator=(const Student &): Memory all ocation errorn"; exit(-1); } for(int i=0; i<num_grades; i++) grades[ i ]= rhs.grades[ i ]; } } intStudent::get_level()const { return level; } intStudent::get_num_grades()const { return num_grades; } doubleStudent::get_grade(int i)const { if(i<1|| i>num_grades) return-1.0;//non-existent grade else return grades[ i-1]; } voidStudent::set_level(int lvl) { level = lvl; } voidStudent::set_num_grades(int num) { num_grades = num;
  • 18. if(num >0){ grades =newdouble[ num ]; if(grades == NULL ){ cerr<<"Student:set_num_grades(int ): Memory allocation errorn"; exit(-1); } for(int i=0; i<num; i++) grades[ i ]=0; } } voidStudent::set_grade(int i,double grd) { if(i>=1&& i<=num_grades) grades[ i-1]= grd; } ostream&operator<<(ostream& out,constStudent& std) { DayOfYear bday; bday = std.get_birthday(); out <<"------------------------------n"; out <<"id="<< std.get_id()<<endl; out <<"name="<< std.get_name()<< endl; out <<"birthday="<< bday.get_day(); out <<"-"<< bday.get_month(); out <<"-"<< bday.get_year()<< endl; out <<"#emails="<<std.get_num_emails()<<endl; out <<" 1st email="<< std.getEmail(0)<<endl; out <<"level="<<std.level<<endl; out <<"#grades="<< std.num_grades <<endl; for(int i=1; i<=std.num_grades; i++) out <<"grade["<< i <<"]="<< std.grades[i-1]<<" "; out <<endl;
  • 19. out <<"------------------------------n"; return out; } voidStudent::output()const { DayOfYear bday; bday = get_birthday(); cout <<"------------------------------n"; cout <<"id="<< get_id()<<endl; cout <<"name="<< get_name()<< endl;//private-is- private rule cout <<"birthday="<< bday.get_day(); cout <<"-"<< bday.get_month(); cout <<"-"<< bday.get_year()<< endl; cout <<"#emails="<<get_num_emails()<<endl; cout <<" 1st email="<< getEmail(0)<<endl; cout <<"level="<<level<<endl; cout <<"#grades="<< num_grades <<endl; for(int i=1; i<=num_grades; i++) cout <<"grade["<< i <<"]="<< grades[i-1]<<" "; cout <<endl; cout <<"------------------------------n"; } Q2/student.h //File name--student.h: declare Student as a derived class of Person #ifndef _STUDENT_H
  • 20. #define _STUDENT_H #include "person.h" class Student:public Person { public: ~Student(); //destructor Student(); //default: 1->level, 0->num_grades, NULL- >grades Student(int new_id, string new_name, DayOfYear date, int lvl ); //lvl->level, 0->num_grades, NULL->grades Student(const Student& std); //copy constructor: std -- >*this void operator=(const Student& rhs); //rhs --> *this int get_level() const; //return level int get_num_grades() const; //return num_grades double get_grade(int i) const; //return grades[i] void set_level(int lvl); //lvl-->level
  • 21. void set_num_grades( int num); //num->num_grades, allocate memory to *grades void set_grade(int i, double grd); //grd --> grades[i] friend ostream & operator <<( ostream & out, const Student& std); virtual void output() const; //print out a student's info. private: int level; //1-4: freshmen, sophomore, junior and senior int num_grades; double *grades; }; #endif //_STUDENT_H Q1/9.cpp #include <iostream> #include "figure.h" #include "rectangle.h" #include "triangle.h"
  • 22. using std::cout; int main() { Triangle tri; tri.draw(); cout << "nDerived class Triangle object calling" << " center().n"; tri.center(); Rectangle rect; rect.draw(); cout << "nDerived class Rectangle object calling" << " center().n"; rect.center(); return 0; } Each topic must have 150+ words
  • 23. Topic 1: Cherie is an accountant for a large advertising agency. After receiving notice of a prospective, large account, she thinks of a creative advertising campaign and tells her idea to Charles, her manager. Charles shoots down her idea and reminds her that her job is accounting. Several days later, the design team visits Charles and asks him for more details on his brilliant campaign idea. Cherie realizes that the campaign being discussed is her idea. What does this outcome indicate about the communication climate and power holding in the agency? If you were Cherie, would you approach Charles about stealing your idea, or would you show support for your manager? Why? Topic 2: When it comes to coworkers, why are strong interpersonal relationships important in business? How do you build and maintain those relationships while keeping professionalism at the forefront? What are some challenges you face in doing so? What are the key factors upon which coworker relationships are usually based? Tell us about your experiences.