Advertisement
Vladkoheca

DeliveryPerson.java

Dec 6th, 2024
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | Source Code | 0 0
  1. public class DeliveryPerson {
  2.     public String name;
  3.     public int onTimeDeliveries;
  4.  
  5.     public DeliveryPerson(String name, int onTimeDeliveries) {
  6.         this.name = name;
  7.         this.onTimeDeliveries = onTimeDeliveries;
  8.     }
  9.     public String toString() {
  10.         return "The name of the delivery person is: " + name + "\nThe number of the successful deliveries is: " + onTimeDeliveries;
  11.     }
  12.     public void deliverOrder(boolean onTime) {
  13.         if (onTime) {
  14.             onTimeDeliveries++;
  15.             System.out.println("The new number of successful deliveries is: " + onTimeDeliveries);
  16.         } else {
  17.             System.out.println(name + " is late.");
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement