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
- Direct subject assignment should be absent
- Direct count assignment should be absent
- rename guard should be present
- Initial summary should be
Initial: Login issue :: updates 0 - Updated summary should be
Updated: Cannot sign in :: updates 1 - Blank-rename summary should be
Blank rename: Cannot sign in :: updates 1 - new SupportTicket('Printer jam').summary() should be
Printer jam :: updates 0