Classes In Java (5) - COP 3330: Object-Oriented Programming...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
COP 3330: Classes In Java – Part 1 Page 1 © Dr. Mark Llewellyn COP 3330: Object-Oriented Programming Summer 2011 Classes In Java – Part 1 Inheritance Department of Electrical Engineering and Computer Science Computer Science Division University of Central Florida Instructor : Dr. Mark Llewellyn markl@cs.ucf.edu HEC 236, 407-823-2790 http://www.cs.ucf.edu/courses/cop3330/sum2011
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COP 3330: Classes In Java – Part 1 Page 2 © Dr. Mark Llewellyn Classes In Java A class is a group of objects that share common state and behavior. A class is an abstraction or description of an object. An object, on the other hand, is a concrete entity that exists in space and time. OO languages use classes to define the state and behavior associated with objects and to provide a means to create the objects that make up a program. Thus, the class acts as a blueprint or template from which objects can be created (instantiated in OO terms). While car is a class, my car and your car are two instances of the class.
Background image of page 2
COP 3330: Classes In Java – Part 1 Page 3 © Dr. Mark Llewellyn Classes In Java We’ve already seen the UML notation for describing a class, and we will continue to use and expand on this notation as we delve deeper into classes in Java. One thing that you want to get straight now is that developing a class and using a class are two distinct tasks. Developing a class, ultimately, requires that you know all of the inner details of the class and how it works. Using a class does not require that you know anything about how the class actually works, only in how you can utilize the class to solve the problem at hand.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COP 3330: Classes In Java – Part 1 Page 4 © Dr. Mark Llewellyn Classes In Java As an example of this concept, consider the UML diagram of a Loan class as shown below: + Loan() + Loan(annualInterestRate: double, numberOfYears: int, loanAmount:double) + getAnnualInterestRate(): double + getNumberOfYears(): int + getLoanAmount(): double + getLoanDate(): java.util.Date + setAnnualInterestRate(annualInterestRate: double): void + setNumberOfYears(numberOfYears: int): void + setLoanAmount(loanAmount: double): void + getMonthlyPayment(): double + getTotalPayment(): double − annualInterestRate: double − numberOfYears: int − loanAmount: double − loanDate: java.util.Date Loan
Background image of page 4
COP 3330: Classes In Java – Part 1 Page 5 © Dr. Mark Llewellyn Classes In Java Now, let’s write a class that uses the Loan class without ever worrying about how the loan class is actually implemented. In other words, we can use this class without knowing anything more about the class than the methods (and variables) that are available to us outside of the class. The
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/04/2011 for the course COP 3330 taught by Professor Staff during the Summer '08 term at University of Central Florida.

Page1 / 47

Classes In Java (5) - COP 3330: Object-Oriented Programming...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online