SlideShare ist ein Scribd-Unternehmen logo
1 von 9
Downloaden Sie, um offline zu lesen
Encapsulation

Monday, October 14, 13
Encapsulation
• encapsulation is hiding or protecting the implementation details
of an object from users of the object
• this creates an abstraction which allows us to focus on essential
properties rather than inner details

2
Monday, October 14, 13
Private fields
• To encapsulate the fields of an object, we make them private:
public class Point {
private int x;
private int y;
}

• Only visible within the Point class, but not anywhere else

3
Monday, October 14, 13
Accessors
• We need a way for external code to access x and y:
// can’t access private vars
System.out.println("p1 is (" + p1.x + ", " + p1.y + ")");
// Point class, with *accessors*
public class Point {
private int x;
private int y;
public int
return
}
public int
return
}
}
Monday, October 14, 13

getX() {
x;
getY() {
y;
4
Accessors
• Write a program called PointMain that creates a new Point at
(3, 5) and prints a description of the Point
public class Point {
private int x;
private int y;
public Point(int x, int y) {
self.x = x;
self.y = y;
}
public int
return
}
public int
return
}
}
Monday, October 14, 13

getX() {
x;
getY() {
y;
5
Accessors
public class PointMain {
public static void main(String[] args) {
Point p = new Point(3, 5);
System.out.println("p is (" + p.getX() + ", " + p.getY() + ")");
}
}

6
Monday, October 14, 13
Mutators
• Write a method for Point called setLocation that takes two
integers and sets the x and y coordinates of the Point
public class Point {
private int x;
private int y;
public Point(int x, int y) {
self.x = x;
self.y = y;
}
public int
return
}
public int
return
}
}
Monday, October 14, 13

getX() {
x;
getY() {
y;
7
Mutators
public class Point {
private int x;
private int y;
public Point(int x, int y) {
self.x = x;
self.y = y;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public void setLocation(int newX, int newY) {
x = newX;
y = newY;
}
}
Monday, October 14, 13

8
Lab!
• See https://dl.dropboxusercontent.com/u/20418505/Labs/
M2.W3-0.txt

9
Monday, October 14, 13

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (17)

Dynamic Memory allocation
Dynamic Memory allocationDynamic Memory allocation
Dynamic Memory allocation
 
Arrays
ArraysArrays
Arrays
 
Constructor and destructor
Constructor and destructorConstructor and destructor
Constructor and destructor
 
constructors and destructors in c++
constructors and destructors in c++constructors and destructors in c++
constructors and destructors in c++
 
Constructor & Destructor
Constructor & DestructorConstructor & Destructor
Constructor & Destructor
 
Dynamic allocation
Dynamic allocationDynamic allocation
Dynamic allocation
 
16858 memory management2
16858 memory management216858 memory management2
16858 memory management2
 
Memory Management In C++
Memory Management In C++Memory Management In C++
Memory Management In C++
 
Pf presntation
Pf presntationPf presntation
Pf presntation
 
Review constdestr
Review constdestrReview constdestr
Review constdestr
 
C++ Constructor destructor
C++ Constructor destructorC++ Constructor destructor
C++ Constructor destructor
 
Lec 6 14_aug [compatibility mode]
Lec 6 14_aug [compatibility mode]Lec 6 14_aug [compatibility mode]
Lec 6 14_aug [compatibility mode]
 
Memory Management C++ (Peeling operator new() and delete())
Memory Management C++ (Peeling operator new() and delete())Memory Management C++ (Peeling operator new() and delete())
Memory Management C++ (Peeling operator new() and delete())
 
Software Design Thinking
Software Design ThinkingSoftware Design Thinking
Software Design Thinking
 
Hash tables
Hash tablesHash tables
Hash tables
 
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
4Developers 2018: Ile (nie) wiesz o strukturach w .NET (Łukasz Pyrzyk)
 
Introduction to Objective - C
Introduction to Objective - CIntroduction to Objective - C
Introduction to Objective - C
 

Andere mochten auch

2 m3.w1.d2 - interfaces
2   m3.w1.d2 - interfaces2   m3.w1.d2 - interfaces
2 m3.w1.d2 - interfacesJustin Chen
 
2 m2.w2.d1 - oop
2   m2.w2.d1 - oop2   m2.w2.d1 - oop
2 m2.w2.d1 - oopJustin Chen
 
m1.w4.d2 - parameters
m1.w4.d2 - parametersm1.w4.d2 - parameters
m1.w4.d2 - parametersJustin Chen
 
Subir prof tapia 2
Subir prof tapia 2Subir prof tapia 2
Subir prof tapia 2Karla Z
 
2 m2.w5.d1 - superclass
2   m2.w5.d1 - superclass2   m2.w5.d1 - superclass
2 m2.w5.d1 - superclassJustin Chen
 
Architecting for Enterprise with JavaScript
Architecting for Enterprise with JavaScriptArchitecting for Enterprise with JavaScript
Architecting for Enterprise with JavaScriptKurtis Kemple
 
Luas dan volum tabung
Luas dan volum tabungLuas dan volum tabung
Luas dan volum tabungrenatrisea
 
2 m2.w4.d1 - inheritance
2   m2.w4.d1 - inheritance2   m2.w4.d1 - inheritance
2 m2.w4.d1 - inheritanceJustin Chen
 
bahan ajar materi bilangan bulat kelas 7
bahan ajar materi bilangan bulat kelas 7bahan ajar materi bilangan bulat kelas 7
bahan ajar materi bilangan bulat kelas 7renatrisea
 

Andere mochten auch (12)

A success-to-be-shared
A success-to-be-sharedA success-to-be-shared
A success-to-be-shared
 
2 m3.w1.d2 - interfaces
2   m3.w1.d2 - interfaces2   m3.w1.d2 - interfaces
2 m3.w1.d2 - interfaces
 
2 m2.w2.d1 - oop
2   m2.w2.d1 - oop2   m2.w2.d1 - oop
2 m2.w2.d1 - oop
 
m1.w4.d2 - parameters
m1.w4.d2 - parametersm1.w4.d2 - parameters
m1.w4.d2 - parameters
 
Subir prof tapia 2
Subir prof tapia 2Subir prof tapia 2
Subir prof tapia 2
 
2 m2.w5.d1 - superclass
2   m2.w5.d1 - superclass2   m2.w5.d1 - superclass
2 m2.w5.d1 - superclass
 
Adán y Eva un matrimonio ejemplar
Adán y Eva un matrimonio ejemplarAdán y Eva un matrimonio ejemplar
Adán y Eva un matrimonio ejemplar
 
Architecting for Enterprise with JavaScript
Architecting for Enterprise with JavaScriptArchitecting for Enterprise with JavaScript
Architecting for Enterprise with JavaScript
 
EL CRISTIANO Y LAS AFLICCIONES
EL CRISTIANO Y LAS AFLICCIONESEL CRISTIANO Y LAS AFLICCIONES
EL CRISTIANO Y LAS AFLICCIONES
 
Luas dan volum tabung
Luas dan volum tabungLuas dan volum tabung
Luas dan volum tabung
 
2 m2.w4.d1 - inheritance
2   m2.w4.d1 - inheritance2   m2.w4.d1 - inheritance
2 m2.w4.d1 - inheritance
 
bahan ajar materi bilangan bulat kelas 7
bahan ajar materi bilangan bulat kelas 7bahan ajar materi bilangan bulat kelas 7
bahan ajar materi bilangan bulat kelas 7
 

Ähnlich wie 2 m2.w3.d1 - encapsulation

Classes and object
Classes and objectClasses and object
Classes and objectAnkit Dubey
 
#OOP_D_ITS - 3rd - Pointer And References
#OOP_D_ITS - 3rd - Pointer And References#OOP_D_ITS - 3rd - Pointer And References
#OOP_D_ITS - 3rd - Pointer And ReferencesHadziq Fabroyir
 
Constructor in c++
Constructor in c++Constructor in c++
Constructor in c++Jay Patel
 
constructors and destructors
constructors and destructorsconstructors and destructors
constructors and destructorsAkshaya Parida
 
C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewPaulo Morgado
 
Les nouveautés de C# 6
Les nouveautés de C# 6Les nouveautés de C# 6
Les nouveautés de C# 6Microsoft
 
namespace ConsoleApplication15 { class Program { static void Main(stri.docx
namespace ConsoleApplication15 { class Program { static void Main(stri.docxnamespace ConsoleApplication15 { class Program { static void Main(stri.docx
namespace ConsoleApplication15 { class Program { static void Main(stri.docxmaximapikvu8
 
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Abu Saleh
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...MaruMengesha
 
class and objects
class and objectsclass and objects
class and objectsPayel Guria
 
I am writing a program that places bolcks on a grid the the sape of .pdf
I am writing a program that places bolcks on a grid the the sape of .pdfI am writing a program that places bolcks on a grid the the sape of .pdf
I am writing a program that places bolcks on a grid the the sape of .pdfeyewaregallery
 
Dynamics allocation
Dynamics allocationDynamics allocation
Dynamics allocationKumar
 
Design pattern - part 3
Design pattern - part 3Design pattern - part 3
Design pattern - part 3Jieyi Wu
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and DestructorsKeyur Vadodariya
 

Ähnlich wie 2 m2.w3.d1 - encapsulation (20)

Classes and object
Classes and objectClasses and object
Classes and object
 
w10 (1).ppt
w10 (1).pptw10 (1).ppt
w10 (1).ppt
 
#OOP_D_ITS - 3rd - Pointer And References
#OOP_D_ITS - 3rd - Pointer And References#OOP_D_ITS - 3rd - Pointer And References
#OOP_D_ITS - 3rd - Pointer And References
 
Constructor in c++
Constructor in c++Constructor in c++
Constructor in c++
 
constructors and destructors
constructors and destructorsconstructors and destructors
constructors and destructors
 
C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 preview
 
Unit 2
Unit 2Unit 2
Unit 2
 
Les nouveautés de C# 6
Les nouveautés de C# 6Les nouveautés de C# 6
Les nouveautés de C# 6
 
namespace ConsoleApplication15 { class Program { static void Main(stri.docx
namespace ConsoleApplication15 { class Program { static void Main(stri.docxnamespace ConsoleApplication15 { class Program { static void Main(stri.docx
namespace ConsoleApplication15 { class Program { static void Main(stri.docx
 
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13Lecture 3, c++(complete reference,herbet sheidt)chapter-13
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...
 
class and objects
class and objectsclass and objects
class and objects
 
Class and object C++.pptx
Class and object C++.pptxClass and object C++.pptx
Class and object C++.pptx
 
662305 10
662305 10662305 10
662305 10
 
I am writing a program that places bolcks on a grid the the sape of .pdf
I am writing a program that places bolcks on a grid the the sape of .pdfI am writing a program that places bolcks on a grid the the sape of .pdf
I am writing a program that places bolcks on a grid the the sape of .pdf
 
C++ prgms 3rd unit
C++ prgms 3rd unitC++ prgms 3rd unit
C++ prgms 3rd unit
 
Dynamics allocation
Dynamics allocationDynamics allocation
Dynamics allocation
 
Design pattern - part 3
Design pattern - part 3Design pattern - part 3
Design pattern - part 3
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Opp compile
Opp compileOpp compile
Opp compile
 

Kürzlich hochgeladen

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 

Kürzlich hochgeladen (20)

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 

2 m2.w3.d1 - encapsulation

  • 2. Encapsulation • encapsulation is hiding or protecting the implementation details of an object from users of the object • this creates an abstraction which allows us to focus on essential properties rather than inner details 2 Monday, October 14, 13
  • 3. Private fields • To encapsulate the fields of an object, we make them private: public class Point { private int x; private int y; } • Only visible within the Point class, but not anywhere else 3 Monday, October 14, 13
  • 4. Accessors • We need a way for external code to access x and y: // can’t access private vars System.out.println("p1 is (" + p1.x + ", " + p1.y + ")"); // Point class, with *accessors* public class Point { private int x; private int y; public int return } public int return } } Monday, October 14, 13 getX() { x; getY() { y; 4
  • 5. Accessors • Write a program called PointMain that creates a new Point at (3, 5) and prints a description of the Point public class Point { private int x; private int y; public Point(int x, int y) { self.x = x; self.y = y; } public int return } public int return } } Monday, October 14, 13 getX() { x; getY() { y; 5
  • 6. Accessors public class PointMain { public static void main(String[] args) { Point p = new Point(3, 5); System.out.println("p is (" + p.getX() + ", " + p.getY() + ")"); } } 6 Monday, October 14, 13
  • 7. Mutators • Write a method for Point called setLocation that takes two integers and sets the x and y coordinates of the Point public class Point { private int x; private int y; public Point(int x, int y) { self.x = x; self.y = y; } public int return } public int return } } Monday, October 14, 13 getX() { x; getY() { y; 7
  • 8. Mutators public class Point { private int x; private int y; public Point(int x, int y) { self.x = x; self.y = y; } public int getX() { return x; } public int getY() { return y; } public void setLocation(int newX, int newY) { x = newX; y = newY; } } Monday, October 14, 13 8