Lecture22 - Java Programming, 3e Concepts and Techniques...

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

View Full Document Right Arrow Icon
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes (IV) ICTN 2730 Lecture 22 03/03/2008
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Assignments Read chapter 5 and lecture notes. Homework 7 is due Wednesday. Please test your programs and make sure they meet the requirements after uploading. Homework 6 grades are available. Homework 6 solutions will be posted and discussed Wednesday.
Background image of page 2
3 Constructor Methods Define an instance of an object Have no return data type Have the same name as the object class Create an instance of the object internally e.g. Rooms(), Reservations(), Label(), Button(), Date()
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Instance Methods An instance method operates or manipulates variables for an external class Instance variables are variables manipulated within an instance method, which are local in scope When called by a driver class, instance methods must use the class.method() notation e.g. f.getName(), f.TaxWithheld() in HW 4; Instance methods typically include a user- friendly active verb in the method name e.g. bookRoom(), getSalary()
Background image of page 4
5 Instance Methods - Example public double getSalary() { double salary ; Scanner scannerIn = new Scanner(System.in); System.out.println("Please enter your salary: "); salary = scannerIn.nextDouble(); return salary; } The instance variable salary is local in scope because it is declared inside the method and is only visible inside the method.
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Creating an External Class An external class is a class that is not a driver class The Rooms class is an external class External classes are declared public to be accessible by all objects and to allow for inheritance
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/29/2008 for the course ICTN 2730 taught by Professor Li during the Spring '08 term at East Carolina University .

Page1 / 24

Lecture22 - Java Programming, 3e Concepts and Techniques...

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

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