Question
Book Icon
Chapter 12, Problem 10PP
Program Plan Intro

“GroupHolder” class

Program Plan:

  • Import required package.
  • Define “Main” class.
    • Define “GroupHolder” class
      • Create an array list “items” from “GroupHolder” class.
    • Method definition for “findGroupNodeFor”
      • Declare variable using “GroupNode” type.
      • Set node “n” to “null”.
      • Set “found” to “false”.
      • Check condition using “while” loop
        • Compute next node.
        • If “n” equal to “s”, then set “found” to “true”.
          • If found, then returns the value of “n”.
          • Otherwise, returns null.
    • Method definition of “addItem”.
      • Call “findGroupNodeFor” method and store it to a variable “n”.
      • If “n” is null, then add it to “items”.
    • Method definition for “getRepresentative”.
      • Call “findGroupNodeFor” method and store it to a variable “n”.
      • Check condition using “while” loop.
        • Set node to link value at node
          • Finally returns the data at node.
    • Method definition of “getAllRepresentatives”.
      • Create an array list.
      • Add data to “items”.
      • Finally returns the result.
    • Method definition of “inSameGroup”.
      • Assign representative for string “s1” and store result to “r1”.
      • Assign representative for string “s2” and store result to “r2”.
      • Returns result.
    • Method definition of “union”
      • Assign representative for string “s1” and store result to “r1”.
      • Assign representative for string “s2” and store result to “r2”.
      • Check condition.
        • Find group node for “r1” and “r2”.
    • Create “GroupNode” class.
      • Declare required variables.
      • Create constructor for “GroupNode” class.
      • Create parameterized for “GroupNode” class.
    • Define main function.
      • Create object “g” from “GroupHolder” class.
      • Add item to “g” by calling the method “addItem”.
      • Display groups by calling the method “getAllRepresentatives”.
      • Join groups by calling the method “union”.
      • Display groups after performing unions operations.
      • Check “a” and “e” is in same group by calling method “inSameGroup”.
      • Check “a” and “f” is in same group by calling method “inSameGroup”.

Blurred answer
Students have asked these similar questions
Start with the initial angles within the integration and just integrate them without mapping them to specific quadrants. Use python and radians
How does encryption prevent a hacker from getting your data
what is one way to secure a phone

Chapter 12 Solutions

Java: An Introduction to Problem Solving and Programming plus MyProgrammingLab with Pearson eText -- Access Card Package (7th Edition)

Ch. 12.1 - Prob. 12STQCh. 12.2 - Prob. 13STQCh. 12.2 - Prob. 14STQCh. 12.2 - Prob. 15STQCh. 12.2 - Prob. 16STQCh. 12.3 - Prob. 17STQCh. 12.3 - Prob. 18STQCh. 12.3 - Prob. 19STQCh. 12.3 - Write a definition of a method isEmpty for the...Ch. 12.3 - Prob. 21STQCh. 12.3 - Prob. 22STQCh. 12.3 - Prob. 23STQCh. 12.3 - Prob. 24STQCh. 12.3 - Redefine the method getDataAtCurrent in...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.4 - Revise the definition of the class ListNode in...Ch. 12.4 - Prob. 30STQCh. 12 - Repeat Exercise 2 in Chapter 7, but use an...Ch. 12 - Prob. 2ECh. 12 - Prob. 3ECh. 12 - Repeat Exercises 6 and 7 in Chapter 7, but use an...Ch. 12 - Write a static method removeDuplicates...Ch. 12 - Write a static method...Ch. 12 - Write a program that will read sentences from a...Ch. 12 - Repeat Exercise 12 in Chapter 7, but use an...Ch. 12 - Write a program that will read a text file that...Ch. 12 - Revise the class StringLinkedList in Listing 12.5...Ch. 12 - Prob. 12ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 14ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 17ECh. 12 - Revise the method selectionSort within the class...Ch. 12 - Repeat the previous practice program, but instead...Ch. 12 - Repeat Practice Program 1, but instead write a...Ch. 12 - Write a program that allows the user to enter an...Ch. 12 - Write a program that uses a HashMap to compute a...Ch. 12 - Write a program that creates Pet objects from data...Ch. 12 - Repeat the previous programming project, but sort...Ch. 12 - Repeat the previous programming project, but read...Ch. 12 - Prob. 9PPCh. 12 - Prob. 10PPCh. 12 - Prob. 11PPCh. 12 - Prob. 12PPCh. 12 - Prob. 13PPCh. 12 - Prob. 14PPCh. 12 - Prob. 15PP
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning