1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Rasek [7]
3 years ago
9

Write a class named Book that has fields to hold the following data: Title Author Year published ISBN number In the Book class,

also include A mutator method for each field to set the value for the field An accessor method for each field to get the value for the field Write a separate demo program that Utilizies the class by creating three instances of the class.
Computers and Technology
1 answer:
Hatshy [7]3 years ago
3 0

Answer:

public class Book {

   private String title;

   private String author;

   private int yearPublished;

   private long ISBN;

   //The Constructor for all the feilds

   public Book(String title, String author, int yearPublished, long ISBN) {

       this.title = title;

       this.author = author;

       this.yearPublished = yearPublished;

       this.ISBN = ISBN;

   }

   //Mutator methods (set) to Set values of all the fields

   public void setTitle(String title) {

       this.title = title;

   }

   public void setAuthor(String author) {

       this.author = author;

   }

   public void setYearPublished(int yearPublished) {

       this.yearPublished = yearPublished;

   }

   public void setISBN(long ISBN) {

       this.ISBN = ISBN;

   }

   //Accessor Methods (getters) for all the feilds

   public String getTitle() {

       return title;

   }

   public String getAuthor() {

       return author;

   }

   public int getYearPublished() {

       return yearPublished;

   }

   public long getISBN() {

       return ISBN;

   }

}

// The Demo Class creating three instances of this class

class BookDemo{

   public static void main(String[] args) {

       Book bookOne = new Book("The Lion and the Princess","David A.",2000,12334556);

       Book bookTwo = new Book ("Me and You", "Jane G.", 2001, 4567342);

       Book bookThree = new Book("together forever", "Baneely H.",2019,34666);

   }

}

Explanation:

  • Please pay attention to the comments provided in the solution
  • Using Java Programming Language
  • The class Book is created with the required fields
  • The constructor is created to initialize the values of the fields
  • Getter methods are created
  • Setter Methods are Created
  • A demo Class BookDemo that creates three objects of the Book class is the created (This can be in the same file as the Book class but cannot start with the keyword public or in a separate file with the keyword public class BookDemo)
  • Inside BookDemo class, three instances of the Book class are created and initialized.
You might be interested in
What does the key combination ctrl+s achieve?
erastovalidia [21]
Control + S I suppose saves files
7 0
4 years ago
Read 2 more answers
I NEED HELP!! THIS IS 3D COMPUTER MODELING COURSE IN CONNEXUS
Papessa [141]

6. x, y, and z (x is right, z is forward, and y is up)

7. true

8. plane

9. Cartesian grid

10. They describe a location using the angle and distance from the original.

11. effects that alter the look of an object.

12. true

13. true

14. (not sure, but I would go with conceptual)

15. 3-D elements

Hope this helps! Please let me know if you need more help, or if you think my answer is incorrect. Brainliest would be MUCH appreciated. Have a great day!

Stay Brainy!

8 0
2 years ago
Combustion is an example of to energy conversion.
Marizza181 [45]
If this is a true or false question I would say true... but I dont know I’m confusion <3
7 0
3 years ago
What is the code i need to do
Greeley [361]
What section is it? I did the same thing a bit ago on edhesive
3 0
3 years ago
Technological _____ is the term used to describe the merging of several technologies into a single device.
Sophie [7]

The answer is convergence.

3 0
3 years ago
Other questions:
  • Bar-code readers are typically used to track large numbers of inventory items, as in grocery store inventory and checkout, packa
    14·1 answer
  • Consider the following list.
    5·1 answer
  • Where can you access all the formatting options for worksheet cells?
    5·1 answer
  • Consider a bit stuffing framing method where the start of a frame is indicated by 6 consecutive ones, followed by 2 zeroes. What
    8·1 answer
  • What kinds of online behaviors could be considered cyberbullying?
    7·2 answers
  • If you reset your iPhone will it delete everything including your Apple ID information
    9·2 answers
  • Describe how data center storage applications drive the development of SAN technology.
    8·1 answer
  • What memory stores instructions that tell the computer how to start up?
    10·1 answer
  • To improve readability and maintainability, you should declare ________ instead of using literal values such as 3.14159.
    14·1 answer
  • Please help! Python programming, use the factorial operation to evaluate 4!. Answers are in picture please pick one, thank you.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!