This question involves the design of a class that will be used to produce practice problems. The following StudyPracticeinterface represents practice problems that can be used to study some subject.   public interface StudyPractice. { /**Returns the current practive problem */ String getProblem();

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

This question involves the design of a class that will be used to produce practice problems. The following StudyPracticeinterface represents practice problems that can be used to study some subject.

 

public interface StudyPractice.

{

/**Returns the current practive problem */

String getProblem();

 

/** Changes to the next practice problem */

void nextProblem();

}

 

The MultPractice class is a StudyPracticethat produces multiplication practice problems. A MultPractice object is constructed with two integer values: first integer and initial second integer. The first integer is a value that remains constant and is used as the first integer in every practice problem. The initial second integer is used as the starting value for the second integer in the practice problems. This second value is incremented for each additional practice problem that is produced by the class.

For example, a MultPractice object created with the call new MultPractice (7, 3)would be used to create the practice problems"7 TIMES 3","7 TIMES 4","7 TIMES 5", and so on. In the MultPractice class, the getProblem method returns a string in the format of "first integer TIMES second integer". The nextProblem method updates the state of the MultPractice object to represent the next practice problem.

 

The following examples in the attachments illustrate the behavior of the MultPracticeclass. Each table shows a code segment and the output that would be produced as the code is executed.

Accordingly, write the complete MultPractice class. Your implementation must be consistent with the specifications and the given examples.

Code segment
StudyPractice
p2
p2.next Problem ();
=
System.out.println
System.out.println
new MultPractice (4, 12);
(p2.get Problem () );
(p2.get Problem () );
p2.next Problem ();
p2.next Problem ();
System.out.println (p2.getProblem () );
p2.next Problem ();
System.out.println (p2.get Problem () );
Output produced
4 TIMES 13
4 TIMES 13
4 TIMES 15
4 TIMES 16
Transcribed Image Text:Code segment StudyPractice p2 p2.next Problem (); = System.out.println System.out.println new MultPractice (4, 12); (p2.get Problem () ); (p2.get Problem () ); p2.next Problem (); p2.next Problem (); System.out.println (p2.getProblem () ); p2.next Problem (); System.out.println (p2.get Problem () ); Output produced 4 TIMES 13 4 TIMES 13 4 TIMES 15 4 TIMES 16
Code segment
StudyPractice
p2
p2.next Problem ();
=
System.out.println
System.out.println
new MultPractice (4, 12);
(p2.get Problem () );
(p2.get Problem () );
p2.next Problem ();
p2.next Problem ();
System.out.println (p2.getProblem () );
p2.next Problem ();
System.out.println (p2.get Problem () );
Output produced
4 TIMES 13
4 TIMES 13
4 TIMES 15
4 TIMES 16
Transcribed Image Text:Code segment StudyPractice p2 p2.next Problem (); = System.out.println System.out.println new MultPractice (4, 12); (p2.get Problem () ); (p2.get Problem () ); p2.next Problem (); p2.next Problem (); System.out.println (p2.getProblem () ); p2.next Problem (); System.out.println (p2.get Problem () ); Output produced 4 TIMES 13 4 TIMES 13 4 TIMES 15 4 TIMES 16
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education