Question

In this assignment, you need to create a class to keep track of books borrowed bya student. Each book has a name, Student (who borrowed it), and the date that was borrowed (see the .h file below). Use also need to use the Person class and the Student class included in the folder. Student class inherits from the Person class as was shown in the classroom Create a Date class (in the same project of the Person and Student classes). An instant of Date class is included in the private variables of the Person class as shown in the Person.h file. The Date class has three integers: Month, Day, and Year. 2- Write all accessors and modifiers for the Date class 3- Write a default and overloaded constructor 4- Overload the operator << to print a date. 5- Create a Books class (also in the same project) Copy and paste the code below in Books.h. Implement following member functions in Books.cpp (default and overloaded constructors ,getstudent () and getBook ), and overload the operator <<) Write the bool not. A book is overdue if it has been borrowed for over one month or in a different year. Ignore the case of December of the previous year 6- overdue (Date &current) to test if the book is overdue or 7- In main ), create a Person object and date of birth. Then a Student object. Then create a Book object and its Date when it was borrowed. Last, create a Date current. Set current to the 1/1/2018 using the Date overloaded constructor. Then compare the date of the borrowed book to the current date and return a message stating if the book is overdue or not
media%2F626%2F62630e3e-8843-481c-a472-c6
Student.h

media%2Fbd0%2Fbd0055cf-9a93-4cb0-a62c-70
Student.cpp

media%2F0a8%2F0a83128b-9b62-4978-a316-df
Person.h

media%2F7cf%2F7cf80163-68ed-4af8-9d17-46
Person.cpp

media%2Ff6a%2Ff6acfa80-1eb9-4b17-a428-51

media%2F86a%2F86acbe30-1839-43f0-b04e-f6
0 0
Add a comment Improve this question Transcribed image text
Answer #1

here is your remaining files : ----------->>>>>

Date.h : ------->>>>>>>>>.

#ifndef DATE_H
#define DATE_H
#include<iostream>

using namespace std;

class Date{
private:
  int month;
  int year;
  int day;
public:
  Date();
  Date(int day,int month,int year);
  void operator=(const Date &d);
  int getMonth() const;
  int getYear() const;
  int getDay() const;
  void setDay(int d);
  void setMonth(int m);
  void setYear(int y);
  
  friend ostream& operator<<(ostream &out,Date &d);
};

#endif

Date.cpp: --------->>>>>>>

#include "Date.h"

Date::Date(){
day = 0;
month = 0;
year = 0;
}
Date::Date(int day,int month,int year){
this->day = day;
this->month = month;
this->year = year;
}

void Date::setDay(int d){
day = d;
}
void Date::setMonth(int m){
month = m;
}
void Date::setYear(int y){
year = y;
}
int Date::getDay()const{
return day;
}
int Date::getMonth() const{
return month;
}
int Date::getYear() const{
return year;
}
void Date::operator=(const Date &d){
day = d.day;
month = d.month;
year = d.year;
}
ostream& operator<<(ostream &out,Date &d){
string arr[12] = {"Jan.","Feb.","Mar.","Apr.","May","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."};
out<<d.getDay()<<" "<<arr[d.getMonth() - 1]<<", "<<d.getYear();

return out;
}

Books.h : --------------->>>>>>

#include<string>
#include<vector>
#include "Person.h"
#include<iostream>

using namespace std;

class Books{
private:
  string b_name;
  Student s;
  Date date_borrow;
public:
  Books();
  Books(string b,Student s,Date d);
  Books(const Books &book);
  Student getStudent();
  String getBook();
  Date getDate();
  bool overdue(Date &current);
  friend ostream& operator<<(ostream &out,Books &bk);
};

Books.cpp : -------------->>>>>>>>>>

#include "Books.h"

Books::Books(const Books &book){
b_name = book.b_name;
s = book.s;
date_borrow = book.date_borrow;
}

Books::Books(string b,Student s,Date d){
date_borrow = d;
this->s = s;
b_name = b;
}
Books::Books(){

}
string Books::getBook(){
return b_name
}
Student Books::getStudent(){
return s;
}
bool Books::overdue(Date &current){
if(date_borrow.getYear() > current.getYear()){
  return true;
}
if(date_borrow.getYear() == current.getYear()){
  if(date_borrow.getMonth() > current.getMonth()){
   return true;
  }
  
  return false;
}

return false;
}
Date Books::getDate(){
return date_borrow;
}

ostream& operator<<(ostream &out,Books &bk){
out<<"Book Name : "<<bk.getBook()<<endl;
out<<"Student : "<<bk.getStudent();
out<<"\nBorrow Date : "<<bk.getDate();

return out;
}

Add a comment
Know the answer?
Add Answer to:
Student.h Student.cpp Person.h Person.cpp In this assignment, you need to create a class to keep track...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • solve it in c++10 Create a composition between the classes Job and Salary. Class Salary a....

    solve it in c++10 Create a composition between the classes Job and Salary. Class Salary a. data member:    1. money b. constructors:    1. default constructor    2. user defined constructor with a parameter to set money c. standard accessor and mutator functions Class Job a. data members:    title (name of the job)    salary (object of type Salary) b. constructors:    1. default constructor    2. user defined constructor to set title and salary    3. implement constructor delegation c. standard accessor and mutator function...

  • 1. Create an “include guard” (all lines of code required) for a file “plane.h” 2. When...

    1. Create an “include guard” (all lines of code required) for a file “plane.h” 2. When you look at a constructor, how can you determine if it is THE default constructor? 3. What can a “friend” function do that other non-member functions can not do? 4. class plane { int x;} ---------------- is x public or private? 5. What kind of a search first sorts the data into ascending or descending order, then splits the data in half, searches, splits,...

  • In C++: Implement a class Polynomial that uses a dynamic array of doubles to store the...

    In C++: Implement a class Polynomial that uses a dynamic array of doubles to store the coefficients for a polynomial. This class does not need the method the overloaded += operator. Your class should have the following methods: Write one constructor that takes an integer n for the degree of a term and a double coefficient c for the coefficient of the term and creates the polynomial c x^n. (This constructor can be given default arguments easily to have a...

  • Overload a relational operator for the Job class: Assume that this operator is not overloaded for...

    Overload a relational operator for the Job class: Assume that this operator is not overloaded for the Salary class. a) Write how the function will be declared in your code. b) Write an external function definition (not inside the class). solve it in C++10 to solve this you nedd question number 1. Create a composition between the classes Job and Salary. Class Salary a. data member:    1. money b. constructors:    1. default constructor    2. user defined constructor with a parameter...

  • Question 3: Q3 (Polymorphism & virtual function) a) Consider the class, derived class, and the virtual functions as shown in Display for Q3. Create a derived class (of Sale) called 'Mailorder...

    Question 3: Q3 (Polymorphism & virtual function) a) Consider the class, derived class, and the virtual functions as shown in Display for Q3. Create a derived class (of Sale) called 'MailorderSale' having one private member variable called 'shipping charge'. It should have constructor function and virtual function 'bill' (this function adds shipping charge to the price). Define all these functions (no need of default constructors). b) In the main function, define one object of DiscountSale with (11,10) initial values and...

  • C++ In this assignment, you will write a class that implements a contact book entry. For...

    C++ In this assignment, you will write a class that implements a contact book entry. For example, my iPhone (and pretty much any smartphone) has a contacts list app that allows you to store information about your friends, colleagues, and businesses. In later assignments, you will have to implement this type of app (as a command line program, of course.) For now, you will just have to implement the building blocks for this app, namely, the Contact class. Your Contact...

  • it's a JAVA program. Share Edit & Create aanmethod that tests all three overloaded methods. Save...

    it's a JAVA program. Share Edit & Create aanmethod that tests all three overloaded methods. Save the application as Billing.java. a. Create a FitnessTracker class that includes data fields for a fitness activity the number of minutes spent participating, and the date. The class includes methods to get each field. In addition, create a default constructor that automatically sets the activity to running, the minutes to 0, and the date to January 1 of the current year. Save the file...

  • C++ project we need to create a class for Book and Warehouse using Book.h and Warehouse.h header ...

    C++ project we need to create a class for Book and Warehouse using Book.h and Warehouse.h header files given. Then make a main program using Book and Warehouse to read data from book.dat and have functions to list and find book by isbn Objectives: Class Association and operator overloading This project is a continuation from Project 1. The program should accept the same input data file and support the same list and find operations. You will change the implementation of...

  • Please help with a source code for C++ and also need screenshot of output: Step 1:...

    Please help with a source code for C++ and also need screenshot of output: Step 1: Create a Glasses class using a separate header file and implementation file. Add the following attributes. Color (string data type) Prescription (float data type) Create a default constructor that sets default attributes. Color should be set to unknown because it is not given. Prescription should be set to 0.0 because it is not given. Create a parameterized constructor that sets the attributes to the...

  • This problem will create a monthly ledger for a user to keep track of monthly bills....

    This problem will create a monthly ledger for a user to keep track of monthly bills.  The program will start by asking the user for an amount of monthly bills to pay.  Design of this solution will involve four classes, some may involve the use of previously written code: Class Design:  OurDate class – update your previously written OurDate class to include a toString() method. Be certain that you still have methods that will setDayFromUser(), setMonthFromUser() and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT