Building Java Programs: A Back To Basics Approach (5th Edition)
Building Java Programs: A Back To Basics Approach (5th Edition)
5th Edition
ISBN: 9780135471944
Author: Stuart Reges, Marty Stepp
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 8, Problem 15E

Explanation of Solution

Program:

//definition of "Line" class

public class Line

{

Β Β Β Β /*create the two objects for the "Point" class*/

Β Β Β Β private Point p1;

Β Β Β Β private Point p2;

Β Β Β Β // definition of constructor

Β Β Β Β public Line(Point p1, Point p2)

Β Β Β Β {

Β Β Β Β Β Β Β Β /*set the points to the "Point" class object*/

Β Β Β Β Β Β Β Β this.p1 = p1;

Β Β Β Β Β Β Β Β this.p2 = p2;

Β Β Β Β }

Β Β Β Β //definition of "getP1" method

Β Β Β Β public Point getP1()

Β Β Β Β {

Β Β Β Β Β Β Β Β // returns this line's first endpoint

Β Β Β Β Β Β Β Β return p1;

Β Β Β Β }

Β Β Β Β //definition of "getP2" method

Β Β Β Β public Point getP2()

Β Β Β Β {

Β Β Β Β Β Β Β Β // returns this line's second endpoint

Β Β Β Β Β Β Β Β return p2;

Β Β Β Β }

Β Β Β Β //definition of "toString" method

Β Β Β Β public String toString()

Β Β Β Β {

/*returns a string representation of this line*/

Β Β Β Β Β Β Β Β return "[" + p1 + ", " + p2 + "]";

Β Β Β Β }

Β Β Β Β //definition of "getSlope" method

Β Β Β Β public double getSlope()

Β Β Β Β {

Β Β Β Β Β Β Β Β //check two points are equal

Β Β Β Β Β Β Β Β if (p1...

Blurred answer

Chapter 8 Solutions

Building Java Programs: A Back To Basics Approach (5th Edition)

Ch. 8.2 - Prob. 11SCPCh. 8.2 - Prob. 12SCPCh. 8.2 - Prob. 13SCPCh. 8.2 - Prob. 14SCPCh. 8.2 - Prob. 15SCPCh. 8.2 - Prob. 16SCPCh. 8.3 - Prob. 17SCPCh. 8.3 - Prob. 18SCPCh. 8.3 - (You must complete Self-Check Problem 7 before...Ch. 8.3 - Prob. 20SCPCh. 8.3 - Prob. 21SCPCh. 8.4 - Prob. 22SCPCh. 8.4 - Prob. 23SCPCh. 8.4 - Prob. 24SCPCh. 8.4 - Prob. 25SCPCh. 8.4 - Prob. 26SCPCh. 8.4 - Prob. 27SCPCh. 8.4 - How does encapsulation allow you to change the...Ch. 8.5 - Prob. 29SCPCh. 8.5 - Prob. 30SCPCh. 8.5 - Prob. 31SCPCh. 8 - Prob. 1ECh. 8 - Add the following mutator method to the Point...Ch. 8 - Add the following accessor method to the Point...Ch. 8 - Add the following accessor method to the Point...Ch. 8 - Add the following accessor method to the Point...Ch. 8 - Add the following accessor method to the Point...Ch. 8 - Add the following mutator method to the TimeSpan...Ch. 8 - Add the following mutator method to the TimeSpan...Ch. 8 - Add the following mutator method to the TimeSpan...Ch. 8 - Add the following mutator method to the Stock...Ch. 8 - Suppose the following BankAccount class has been...Ch. 8 - Add a toString method to the BankAccount class...Ch. 8 - Add a transfer method to the BankAccount class...Ch. 8 - Prob. 14ECh. 8 - Add the following accessor method to your Line...Ch. 8 - Add the following constructor to your Line...Ch. 8 - Add the following accessor method to your Line...Ch. 8 - Write a class called Rectangle that represents a...Ch. 8 - Add the following constructor to your Rectangle...Ch. 8 - Add the following accessor methods to your...Ch. 8 - Add the following method to your Rectangle...Ch. 8 - Add the following method to your Rectangle...Ch. 8 - Add the following method to your Rectangle...Ch. 8 - Prob. 2PPCh. 8 - Prob. 3PP
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.
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
Java Math Library; Author: Alex Lee;https://www.youtube.com/watch?v=ufegX5o8uc4;License: Standard YouTube License, CC-BY