Write the code for the instantiable class bus which


(1a.) Write the code for the instantiable class Bus, which represents a bus that moves passengers around in a simulated city. Bus objects have a ticket price, a maximum capacity of passengers, and a current number of passengers. Implement at least one constructor and three additional methods: one adds passengers without exceeding the capacity, another removes passengers without removing more than are currently riding, and the last method determines the income received for a particular bus based on the number of riders on the bus and the ticket price. No other methods are required. DO NOT USE InputBox or OutputBox objects -- this class is to be considered to be a "helper" class to other classes. If something isn't specified, do something reasonable and comment your assumptions.

(1b.) Write a code fragment that creates two buses, one having a maximum capacity of 40 riders and a ticket price of $0.50, and the other having a maximum capacity of 15 and costing $0.75. Attempt to add 11 passengers to one bus and 22 to the other. Print out the income received for both of these buses. You may assume that an OutputBox object named out exists.

Solution Preview :

Prepared by a verified Expert
Programming Languages: Write the code for the instantiable class bus which
Reference No:- TGS0669602

Now Priced at $40 (50% Discount)

Recommended (90%)

Rated (4.3/5)