Skip to content

Instantly share code, notes, and snippets.

@SoPat712
Created July 22, 2021 23:01
Show Gist options
  • Save SoPat712/764cd5b1f937b9ea615faaaebd976434 to your computer and use it in GitHub Desktop.
Save SoPat712/764cd5b1f937b9ea615faaaebd976434 to your computer and use it in GitHub Desktop.
Java Intermediate: 07/22/2021
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