hw3 - open seats (ie no one’s sitting in them) on the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 302 Homework 3 - Due Thursday, June 23 Name: 1. Write an instantiable class named Bus that has the instance felds numPassengers and numSeats one constructor that takes one parameter, seats , that initializes the instance feld numSeats ( numPassengers should be initialized to zero). the method addPassengers which takes one integer parameter seats and adds that number to numPassengers the method getNumEmptySeats which takes no parameters and returns the number oF
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: open seats (ie no one’s sitting in them) on the bus. Assume that each passenger occupies one seat. 2. Write a Java application (another class) that has a main method which • declares and creates a Bus object with 40 seats • adds 12 passengers to that Bus object • prints out the number oF remaining empty seats via the getNumEmptySeats method call...
View Full Document

This note was uploaded on 08/08/2008 for the course CS 302 taught by Professor Willbenton during the Spring '07 term at University of Wisconsin Colleges Online.

Ask a homework question - tutors are online