ApexSensei

Drills Classes & objects

Protect a support ticket subject

private fields plus public methods let the class enforce its own rules.

Your task

Finish rename and summary(), then run the three debug lines.

class SupportTicket {
    private String subject;
    private Integer updateCount;

    public SupportTicket(String subject) {
        this.subject = subject;
        this.updateCount = 0;
    }

    public void rename(String newSubject) {
    }

    public String summary() {
        return '';
    }
}

Requirements

  1. Direct subject assignment should be absent
  2. Direct count assignment should be absent
  3. rename guard should be present
  4. Initial summary should be Initial: Login issue :: updates 0
  5. Updated summary should be Updated: Cannot sign in :: updates 1
  6. Blank-rename summary should be Blank rename: Cannot sign in :: updates 1
  7. new SupportTicket('Printer jam').summary() should be Printer jam :: updates 0

Sign in to open this drill