اذهب إلى المحتوى

Omar Discord

الأعضاء
  • المساهمات

    2
  • تاريخ الانضمام

  • تاريخ آخر زيارة

إنجازات Omar Discord

عضو مبتدئ

عضو مبتدئ (1/3)

1

السمعة بالموقع

  1. Objective: The objective of this programming assignment is to practice composition in C++ by creating two classes, Book and Author, where the Book class contains an Author object as one of its member variables. Author Class: • Create a class called Author that has the following private attributes: - std::string name (the name of the author) - int birthYear (the year the author was born) • Implement a constructor that takes name and birthYear as parameters and initializes the attributes. • Implement two get methods for name and birthYear. • Implement a member function displayInfo that displays the author's information. Book Class: • Create a class called Book that has the following private attributes: - std::string title (the title of the book) - int publicationYear (the year the book was published) - Author author (an instance of the Author class) • Implement a constructor for the Book class that takes title, publicationYear, name, and birthYear as parameters and initializes the attributes. The constructor should also create an Author object. • Implement get methods for title and publicationYear. • Implement a member function displayInfo that displays the book's information, including the author's information, to the console. Main Function: - In the main function, create at least two Book objects with different titles, publication years, author names, and author birth years. - Use the getter methods to access and display the information of these books. - Ensure that the program correctly displays the information about the books and their authors
×
×
  • أضف...