Class Notes (834,026)
Canada (508,290)
COMP 1405 (38)
Lecture

COMP1005/1405_C16_02112010.pdf

6 Pages
102 Views
Unlock Document

Department
Computer Science
Course
COMP 1405
Professor
Christine Laurendeau
Semester
Fall

Description
Lecture 16 Class 1 //The following class shows the usage of a class and subclass import java.util.ArrayList; class CH7_0Employee { //This is a Class String name; String phoneNumber; int employeeNumber; float hourlyPay; } class Manager extends CH7_0Employee { //This is a class named Manager that shares attributes from the //CH7_0Employee class ArrayList duties; ArrayList subordinates; } Lecture 16 Program 1 //Requires Ch7_1Person to run import java.util.Date; class Ch7_1Details { public static void main (String args[]) { Ch7_1Person p = new Ch7_1Person(); Employee e = new Employee(); Customer c = new Customer(); p.name = "Hank Urchiff"; // own attribute p.phoneNumber = "1-613-555-2328"; // own attribute e.name = "Minnie Mumwage"; // attribute inherited from Person e.phoneNumber = "1-613-555-1231"; // attribute inherited from Person e.employeeNumber = 232867; // own attribute e.hourlyPay = 8.75f; // own attribute c.name = "Jim Clothes"; // attribute inherited from Person c.phoneNumber = "1-613-555-5675"; // attribute inherited from Person c.itemsPurchased.add("Pencil Case"); // own attribute c.purchaseHistory.add(new Date()); // own attribute } } Lecture 16 Class 2 //Required for the CH7_1Details program import java.util.ArrayList; import java.util.Date; class Ch7_1Person { String name; String phoneNumber; } class Employee extends Ch7_1Person { int employeeNumber; float hourlyPay; } class Customer extends Ch7_1Person { ArrayList itemsPurchased; ArrayList purchaseHistory; } Lecture 16 Class 3 //Required for the Ch7_2SavingAccount Program public class CH7_2BankAccount { static int LAST_ACCOUNT_NUMBER = 100000; String owner; // person who owns the account int accountNumber; // the account number float balance; // amount of money currently in the account // CH7_2BankAccount constructors CH7_2BankAccount() { this.owner = ""; this.accountNumber = LAST_ACCOUNT_NUMBER++; this.balance = 0; } C
More Less

Related notes for COMP 1405

Log In


OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit