subject

Write a class named book containing: three instance variables named title, author, and tableofcontents of type string. the value of tableofcontents should be initialized to the empty string. an instance variable named nextpage of type int, initialized to 1. a constructor that accepts two string parameters. the value of the first is used to initialize the value of title and the value of the second is used to initialize author. a method named addchapter that accepts two parameters. the first, of type string, is the title of the chapter; the second, is an integer containing the number of pages in the chapter. addchapter appends (that is concatenates) a newline followed by the chapter title followed by the string "" followed by the value of the nextpage instance variable to the tableofcontents. the method also increases the value of nextpage by the number of pages in the chapter. a method named getpages that accepts no parameters. getpages returns the number of pages in the book. a method named gettableofcontents that accepts no parameters. gettableofcontents returns the values of the tableofcontents instance variable. a method named tostring that accepts no parameters. tostring returns a string consisting of the value of title, followed by a newline character, followed by the value of author.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 02:30
If you turn on the lock alpha button , what happens
Answers: 1
question
Computers and Technology, 22.06.2019 03:00
You install teamviewer on your workstation at home so that you can ac ess it when on the road. how can you be assured that unknown users cant access your computer through team viewer?
Answers: 2
question
Computers and Technology, 22.06.2019 07:00
Robots with telescoping arms are sometimes used to perform tasks (e.g., welding or placing screws) where access may be difficult for other robotic types. during a test run, a robot arm is programmed to extend according to the relationship r = 3 + 0.5cos(4θ) and the arm rotates according to the relationship θ=−π4t2+πt , where r is in feet, θ is in radians, and t is in seconds. use a computer program to plot the path of tip a in x and y coordinates for 0 ≤ t ≤ 4s.
Answers: 2
question
Computers and Technology, 22.06.2019 11:10
Which are not examples of chronic or persistent stress? moving
Answers: 1
You know the right answer?
Write a class named book containing: three instance variables named title, author, and tableofconte...
Questions
question
Biology, 18.11.2020 22:40
question
Mathematics, 18.11.2020 22:40
question
Mathematics, 18.11.2020 22:40
question
Chemistry, 18.11.2020 22:40
Questions on the website: 13722363