Created
July 22, 2021 23:01
-
-
Save SoPat712/764cd5b1f937b9ea615faaaebd976434 to your computer and use it in GitHub Desktop.
Java Intermediate: 07/22/2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javafx.test; | |
public class Main { | |
public static void main(String[] args) { | |
// create a book object using 5-arg constructor | |
Book myBook = new Book( | |
"1984", | |
"George Orwell", | |
"Social Sci-Fi", | |
328, | |
5 | |
); | |
// call all getters | |
System.out.println(myBook.getTitle()); | |
System.out.println(myBook.getAuthor()); | |
System.out.println(myBook.getGenre()); | |
System.out.println(myBook.getNumberOfPages()); | |
System.out.println(myBook.getRating()); | |
// call all setters | |
myBook.setTitle("Harry Potter and the Half-Blood Prince"); | |
myBook.setAuthor("J. K. Rowling"); | |
myBook.setGenre("Fantasy Fiction"); | |
myBook.setNumberOfPages(607); | |
myBook.setRating(4.6); | |
// call all getters | |
System.out.println(myBook.getTitle()); | |
System.out.println(myBook.getAuthor()); | |
System.out.println(myBook.getGenre()); | |
System.out.println(myBook.getNumberOfPages()); | |
System.out.println(myBook.getRating()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment