{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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 fields numPassengers and numSeats one constructor that takes one parameter, seats , that initializes the instance field 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

{[ snackBarMessage ]}