Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
3rd Edition
ISBN: 9780134038179
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 18, Problem 3PC
Program Plan Intro

PointList class

Program plan:

  • Import the required package.
  • Create the class “Point” with a type parameter T,
    • Declare necessary variables.
    • Define the constructor.
    • Define the “setx()” and “sety()” methods to set the values for X and Y Coordinates.
    • Define the “getx()” and “gety()” methods to return the values of X and Y Coordinates.
  • Create the class “PointList” that extends the class “Point”,
    • Define the constructor.
    • Define the public method “add()”,
      • Store the value in “ArrayList” using the reference variable “obj”.
        • Define the “toString()” method.
  • Create the class “PointListexam”,
    • Define the method main(),
      • Create the object of a class “Point” as a type of “Integer”.
      • Create the object for the class “PointList” that accepts the object of type Point.
      • Call the “add()” method using the object of “PointList” to fill the values of “ArrayList”.
      • Call the method “toString()” to print elements of “ArrayList”.

Blurred answer
Students have asked these similar questions
17. Phone Book ArrayList Write a class named PhoneBookEntry that has fields for a person's name and phone number. The class should have a constructor and appropriate accessor and mutator methods. Then write a program that creates at least five PhoneBookEntry objects and stores them in an ArrayList. Use a loop to display the contents of each object in the ArrayList.
PyCharm Programming! A Game object knows its name and the number of avators is currently has. It is initialized without Avatars objects. It has a method startGame, which initializes an internal empty list of Avator objects. It has a method to add one Avator object at a time to the Game. It also has a method to remove an Avatar object by the Avatar’s name. A Game object also has a method to animate all its current Avatar objects. Furthermore, it has a method to stopGame, which destroys all current Avator objects in its internal list. The Avatar class creates simple human-type Avatars, which have attributes such as name, hair color, height, superpower. An Avatar object can change its hair color and superpower. It also has a method that “animates” the avatar. The animate() method should simply be a print message such as “Hello! I am …! I have…. hair and my super power is….!”, using the Avatar’s object variables. In main program, create 3 different Avatar objects that resemble 3…
Task 4. Utility classes   Implement a Menu-Driven program of ArrayList class using the above scenario and perform the following operations.                                                                                                                                                 Create an object of ArrayList class based on the scenario with explanations of the method Create a method that will allow inserting an element to ArrayList Class based on the scenario. The input field must be validated as Create a method to delete specific elements in the ArrayList with explanations of the method

Chapter 18 Solutions

Starting Out with Java: From Control Structures through Data Structures (3rd Edition)

Ch. 18.3 - Prob. 18.11CPCh. 18.3 - Prob. 18.12CPCh. 18.3 - Prob. 18.13CPCh. 18.3 - Prob. 18.14CPCh. 18.4 - Prob. 18.15CPCh. 18.5 - Prob. 18.16CPCh. 18.5 - Prob. 18.17CPCh. 18.6 - Prob. 18.18CPCh. 18.6 - Prob. 18.19CPCh. 18.6 - Prob. 18.20CPCh. 18.8 - Prob. 18.21CPCh. 18.8 - Prob. 18.22CPCh. 18.9 - Prob. 18.23CPCh. 18.9 - During the process of erasure, when the compiler...Ch. 18.9 - Prob. 18.25CPCh. 18 - Prob. 1MCCh. 18 - Prob. 2MCCh. 18 - Look at the following method header: void...Ch. 18 - Look at the following method header: void...Ch. 18 - Look at the following method header: void...Ch. 18 - Look at the following method header: void...Ch. 18 - Prob. 7MCCh. 18 - Prob. 8MCCh. 18 - Prob. 9MCCh. 18 - The process used by the Java compiler to remove...Ch. 18 - True or False: It is better to discover an error...Ch. 18 - Prob. 12TFCh. 18 - True or False: Type parameters must be single...Ch. 18 - Prob. 14TFCh. 18 - Prob. 15TFCh. 18 - True or False: You cannot create an array of...Ch. 18 - Prob. 17TFCh. 18 - Prob. 18TFCh. 18 - Prob. 1FTECh. 18 - Assume the following is a method header in a...Ch. 18 - public class MyClassT { public static void...Ch. 18 - public class PointT extends Number super Integer {...Ch. 18 - Assume there is a class named Customer. Write a...Ch. 18 - Assume names references an object of the...Ch. 18 - Prob. 3AWCh. 18 - Prob. 4AWCh. 18 - Prob. 5AWCh. 18 - Prob. 6AWCh. 18 - Prob. 7AWCh. 18 - Prob. 1SACh. 18 - Look at the following method header: public T...Ch. 18 - Prob. 3SACh. 18 - Do generic types exist at the bytecode level?Ch. 18 - Prob. 5SACh. 18 - When the compiler encounters a class, interface,...Ch. 18 - Prob. 1PCCh. 18 - Prob. 2PCCh. 18 - Prob. 3PCCh. 18 - Prob. 4PCCh. 18 - Prob. 5PCCh. 18 - Prob. 6PCCh. 18 - Prob. 7PC
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education