Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This will be written on C++ 1. Create class named Person with the following publ

ID: 3664232 • Letter: T

Question

This will be written on C++

1. Create class named Person with the following public:

(a) getters: i. string getLastName()   ii. string getPassword()

(b) setters: i. void setLastName(string newLastName) ii. void setPassword(string password)

2. Create class named Book with the following public:

(a) getters: i. string getTitle() ii. string getAuthor()

(b) setters: i. void setTitle(string title) ii. void setAuthor(string author)

Keep specification of each class in a seperate file from the implementation of the methods of this class.

That is, create 4 files (2 .cpp files and 2 .h files) We can use private variable in the class.

Explanation / Answer

/**************************************************Person.cpp***************************************/

#include<Person.h>

public class Person
{
   public string last_name;
   public string pass_word;

   public void Person()
   {
       last_name=null;
       pass_word=null;
   }

   public string getLastName()
   {
       cout<<"Enter your last name::"
       getline(cin,ln, ' ');
       return ln;
   }

   public string getPassword()
   {
       cout<<"Enter your password::";
       getline(cin,pw,' ');
       return pw;
   }

   public void setLastName(string newLastName)
   {
       last_name=newLastName;
   }

   public void setPassword(string password)
   {
       pass_word=password;
   }

   int main()
   {
       Person p1 = new Person();

  last_name=p1.getLastName();
       pass_word=p1.getPassword();
       p1.setLastName(last_name);
       p1.setLastName(pass_word);
       cout<<"Your last name is :: "<<last_name;
       cout<<"Your password is :: "<<pass_word;
       return 0;
   }
}

/********************************Person.h**************************/
#include<iostream.h>
#include<stdio.h>
#include<string.h>

string ln = null;
string pw = null;

/***************************Book.cpp***********************************/

#include<Book.h>

public class Book
{
   public string _title;
   public string _author;

   public void Book()
   {
       title=null;
       author=null;
   }

   public string getTitle()
   {
       cout<<"Enter the title of the book::"
       getline(cin,tl, ' ');
       return tl;
   }

   public string getAuthor()
   {
       cout<<"Enter the Author of the book::";
       getline(cin,au,' ');
       return au;
   }

   public void setTitle(string title)
   {
       _title=title;
   }

   public void setAuthor(string author)
   {
       _author=author;
   }

   int main()
   {
       Book b1 = new Book();

       _title=b1.getTitle();
       _author=b1.getAuthor();
       b1.setTitle(_title);
       b1.setAuthor(_author);
       cout<<"Book's title is :: "<<_title;
       cout<<"Book's Author is :: "<<_author;
       return 0;
   }
}

/**********************************Book.h*******************************************/
#include<iostream.h>
#include<stdio.h>
#include<string.h>

string tl = null;
string au = null;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote