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
masha68 [24]
3 years ago
6

Create a class Book with two private int fields, numPages and currentPage. Supply a constructor that takes one parameter and set

s numPages to that value and currentPage to 1. Provide accessor methods for both fields. Also provide a method nextPage that increments currentPage by 1, but only if currentPage is less than numPages.
Computers and Technology
1 answer:
Law Incorporation [45]3 years ago
4 0

Answer:

The code is in the explanation.

Explanation:

/*Creating the class*/

public class Book{

      /*Here we put the attributes of the class;

      In our case, they are the two private ints*/

      private int numPages;

      private int currentPage;

    /*Here is the constructor.

    The constructor always has the same name as the class

     In (), are the parameters.*/

     public Book(int numberOfPages){

                numPages = numberOfPages; /*sets numPages to the value

                                                                    of the parameter*/      

               currentPage = 1; /*sets currentPage to 1*/    

}

   /*An acessor method is a method with which we can get the value of a      variable*/

    /*Acessor method for numPages*/

   /*numPages is an int, so the acessor method returns an int*/

    public int getnumPages(){

            return numPages;

    }

    /*Acessor method for currentPage*/

    public int getcurrentPage(){

           return currentPage;    

     }

     /*Method next page*/

     /*This method does not return anything, so it is a void method*/

     public void nextPage(){

     /*Verify that currentPage is less than numPages*/

     if (currentPage < numPages){

             currentPage = currentPage + 1;

     }

     }

}

You might be interested in
The ____ is a well-established organization with a primary emphasis on computer science. a. International Standards Organization
Pavlova-9 [17]

Answer:

c.

Explanation:

Based on the information provided within the question it can be said that the organization that is being mentioned is called the The Association for Computing Machinery (ACM). This association was founded in 1947 is the largest computing society in the world, with it's main focus being on computer science and education.

3 0
4 years ago
Google's stated mission is to: establish itself as the most valuable media company in the world. organize the world's informatio
pickupchik [31]

Answer:

Yes this is true.

Explanation:

7 0
3 years ago
What font family is Times New Roman an what font family is Arial?
Alexxandr [17]

Answer:

Some Font Examples

Generic Font Family                 Examples of Font Names

Serif                    Times New Roman Georgia Garamond

Sans-serif                          Arial Verdana Helvetica

Monospace                     Courier New Lucida Console Monaco

Cursive                        Brush Script MT Lucida Handwriting

Explanation:

hope it help

4 0
3 years ago
Read 2 more answers
What are binary code​
s2008m [1.1K]

Answer:

Binary code is a coding system using binary digits 0 and 1 to represent a letter, digit, or other characters in a computer or other electronic device. The binary code assigns a pattern of binary digits, also known as bits, to each character, instruction, etc.

3 0
3 years ago
Read 2 more answers
Create a public non-final class named Larger parameterized by a type T that implements Comparable. (Please use T or the test sui
Liula [17]

Answer:

see explaination

Explanation:

class Larger<T extends Comparable<T>> {

public boolean larger(T[] arr, T item) {

if (arr == null || item == null)

throw new IllegalArgumentException();

for (int i = 0; i < arr.length; i++) {

if (item.compareTo(arr[i]) < 0) {

return false;

}

}

return true;

}

}

3 0
3 years ago
Other questions:
  • Explain where and why metallic material or non metallic material have been used in your home​
    8·1 answer
  • how to create a program that prime number include arraylist , and if not print the prime factors of the number.
    13·1 answer
  • To run a PHP application that has been deployed on your own computer you can enter a URL in the address bar of your browser that
    7·1 answer
  • All resources are limited. Which of the following is NOT a resource?
    11·1 answer
  • Productivity can best be described as:
    5·2 answers
  • In cell e9, enter a formula that calculates the session fee for a member. members receive a member discount off the non-member s
    9·1 answer
  • Pls help with this (20 points again)
    8·1 answer
  • Cómo se hacían antes las cosas que hoy en día se hacen apoyadas en aplicaciones y software?
    10·1 answer
  • Peyton is taking a part-time job to earn some extra money. Every week the manager will provide a list of tasks and the number of
    11·1 answer
  • In your own words discuss 4 major strength and weakness<br> of<br> computer
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!