Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 . Requirements 7 : 4 5 PM Sun Jul 2 1 CourseDemo Q Done This class stores data about an instructor. * / public

1. Requirements 7:45 PM Sun Jul 21
CourseDemo
Q
Done This class stores data about an instructor.
*/
public class Instructor
{private String firstName; // First name/** first name, and office number. @param fname The instructor's first name.*/ String office) lastName = lname;}/** as a copy of another Instructor object.*/{ firstName = object2.firstName;} The set method sets a value for each field. @param fname The instructor's first name.*/ String office) lastName = lname; officeNumber = office;/** @return A string containing the instructor*/{ String str = "Last Name: "+ lastName +"\moffice Number: "t ott7cenumber: \ private String firstName; // First name/** first name, and office number. @param fname The instructor's first name.*/ String office) lastName = lname; officeNumber = office;/** as a copy of another Instructor object.*/{ firstName = object2.firstName;} The set method sets a value for each field. @param fname The instructor's first name.*/ String office) lastName = lname; officeNumber = office;/** @return A string containing the instructor*/{ String str = "Last Name: "+ lastName +"
Office Number: "+ officeNumber; return str;} courseName = name;// instr as an argument to the copy constructor.// Create a new TextBook object, passingtextBook = new TextBook(text);/** @return The name of the course.public String getName() return courseName;/** @return A reference to a copy of this course's*/{ return new Instructor(instructor);/** @return A reference to a copy of this course's*/{ return new TextBook(textBook);/** @return A string containing the course information.public String toString()// Create a string representing the object. "
Instructor Information:
"+"
Textbook Information:
"+// Return the string.}
}private String author; // Author's last name
private String publisher; // Name of publisher
??**
This constructor initializes the title,
author, and publisher fields
@param textTitle The book's title.
@param auth The author's name.
@param pub The name of the publisher.
*?
public TextBook(String textTitle, String auth,
String pub)
{
title = textTitle;
author = auth;
}
publisher = pub;
??**
The copy constructor initializes the object
as a copy of another TextBook object.
@param object2 The object to copy.
*/
public TextBook(TextBook object2)
{
title = object2.title;
author = object2.author;
publisher = object2.publisher;
}
??**
The set method sets a value for each field.
@param textTitle The book's title.
@param auth The author's name.
@param pub The name of the publisher.
*/
public void set(String textTitle, String auth,
String pub)
{
title = textTitle;
author = auth;
publisher = pub;
}
??**
toString method
@return A string containing the textbook
information.
*?
public String toString()
{
// Create a string representing the object.
String str = "Title: "+ title +
"
Author: "+ author +
"
Publisher: "+ publisher;
// R
In this assignment, you will modify the provided sample code that includes
Instructor.java, TextBook.java, Course.java and CourseDemo.java. The 4 programs
work together with aggregation. The following modifications are required:
1) Add a field variable in Course.java to represent course number (e.g., CSCI 1302)
so that a course object will include course number, course name, instructor, and
textbook. You may need to modify the rest of Course.java accordingly due to the
addition of course number variable [20 marks].
2) Add a constructor Course(Course object2) to Course.java so that a course can be
constructed from another course [10 marks].
3) Modify CourseDemo.java to create 5 different instructor objects, 5 different
textbook objects and 5 different course objects. The 5 instructors and 5 textbooks
must be used in defining the 5 course objects so that each course object has a
different instructor and a different textbook. Please store 5 instructor objects in an
instructor array, 5 textbook objects in a textbook array, and 5 courses in a course
array [40 marks].
4) Use a loop to go through the course array and print the full information of 5
courses. Please ensure the output is properly formatted via the toString() method
[20 marks].
5) Please produce a screenshot to show how your program works [5 marks].
6) Please comment your code properly (e.g., header comment, code comment) and
follow professional programming style (e.g., indentations, naming, etc.)[5 marks].
2. Submission
1) Your code (Course.java, Instructor.java, TextBook.java, CourseDemo.java).
2) Screenshots showing how your code works
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions

Question

2. What do you think of the overbooking policy?

Answered: 1 week ago