Created
July 22, 2021 23:01
-
-
Save SoPat712/f2de9da96b6365a1c12261d5a3590735 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 Book { | |
private String title; | |
private String author; | |
private String genre; | |
private int numberOfPages; | |
private double rating; | |
public Book() { | |
title = ""; | |
author = ""; | |
genre = ""; | |
numberOfPages = 0; | |
rating = 0; | |
} | |
public Book( | |
String title, | |
String author, | |
String genre, | |
int numberOfPages, | |
double rating | |
) { | |
this.title = title; | |
this.author = author; | |
this.genre = genre; | |
this.numberOfPages = numberOfPages; | |
this.rating = rating; | |
} | |
public String getTitle() { | |
return title; | |
} | |
public void setTitle(String title) { | |
this.title = title; | |
} | |
public String getAuthor() { | |
return author; | |
} | |
public void setAuthor(String author) { | |
this.author = author; | |
} | |
public String getGenre() { | |
return genre; | |
} | |
public void setGenre(String genre) { | |
this.genre = genre; | |
} | |
public int getNumberOfPages() { | |
return numberOfPages; | |
} | |
public void setNumberOfPages(int numberOfPages) { | |
if (numberOfPages >= 0) { | |
this.numberOfPages = numberOfPages; | |
} | |
} | |
public double getRating() { | |
return rating; | |
} | |
public void setRating(double rating) { | |
if (rating >= 0 && rating <= 5) { | |
this.rating = rating; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment