ApexSensei

Drills Classes & objects

Initialize a service appointment

A constructor runs when new builds an object, so every new object starts with a valid state.

Your task

Finish the AppointmentPlan constructor and build three plans.

class AppointmentPlan {
    public String customerName;
    public Integer durationMinutes;

    public AppointmentPlan(String customerName, Integer durationMinutes) {
    }

    public String summary() {
        return customerName + ' :: ' + durationMinutes + ' min';
    }
}

Requirements

  1. Declares the two-parameter constructor should be present
  2. Standard plan should be Standard: Acme onboarding :: 45 min
  3. Half-hour plan should be Half-hour: Data review :: 30 min
  4. Zero-minute plan should be Zero minutes: Quick check :: 15 min
  5. Short-length plan should be Team sync :: 15 min
  6. Long-length plan should be Kickoff :: 90 min

Sign in to open this drill