Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Java Programming Assignment #7: Literary Objects

This assignment incorporates object-oriented programming techniques. While you may choose
to add more to your classes, you must have the following at a minimum:

1. Write a Java class Author with following features:

Fields: firstName, lastName

Constructor: accepts and initializes firstName and lastName

Methods: setFirstName, setLastName, getFirstName, getLastName, toString which returns


authors name as a String (formatted however you like)

2. Write a Java class Book with following features:

Fields: title, author (of type Author as created above), price

Constructor: accepts and initializes title, author (of type Author as created above), and price

Methods: setTitle, setAuthor, setPrice, getTitle, getAuthor, toString which returns the book’s
details as a String (formatted however you like)

3. Write a separate class BookTest with a main() method which:

- creates a Book titled “Java Solutions” with author Mo Programs, priced at 34.99
- prints the Book’s string representation to standard output (using System.out.println)

You might also like