{"id":"code-col-java-class-stub-from-uml","audience":"college","category":"coding","track":"coding","technique":"constraints","title":"Turn a UML box into a Java class stub for your team","free":false,"task":"Your team splits work by class, so you're writing the LibraryCard skeleton from the UML for teammates to fill in. Team rules: the class is public final, fields are private final with the UML names, the constructor stores loans as a defensive copy with List.copyOf(loans), there's a getter for each field and no setters, and checkout and returnBook stubbed with throw new UnsupportedOperationException(\"TODO\"). Your course bans records and Lombok. Exactly 1 code block of at most 34 lines, under 20 words of text.","materialLabel":"The UML and team notes (attached to your prompt automatically)","material":"CS 2340 team project \"ShelfShare\" - class diagram (excerpt)\n\n+---------------------------------------------+\n|                LibraryCard                  |\n+---------------------------------------------+\n| - cardId : String                           |\n| - ownerName : String                        |\n| - loans : List<Book>                        |\n+---------------------------------------------+\n| + LibraryCard(cardId: String,               |\n|               ownerName: String,            |\n|               loans: List<Book>)            |\n| + getCardId() : String                      |\n| + getOwnerName() : String                   |\n| + getLoans() : List<Book>                   |\n| + checkout(book: Book) : boolean            |\n| + returnBook(book: Book) : void             |\n+---------------------------------------------+\n\nRules (from the team doc):\n- checkout returns false if the card already has 5 loans  <- Priya\n  will implement checkout + returnBook next week\n- Book is in the same package (com.shelfshare.model)\n- Java 17, but the professor's style guide says \"no records, no Lombok,\n  write classes out by hand so we practice encapsulation\"\n\nAssignment of classes: Book (Luis), LibraryCard (you), Branch (Priya)","rules":[{"type":"codeBlocks","count":1},{"type":"maxCodeLines","max":34},{"type":"maxProseWords","max":20}],"mistakes":[{"title":"Getting it implemented","why":"The AI writes the 5-loan check, which is Priya's task next week.","fix":"Say: \"Stub checkout and returnBook with throw new UnsupportedOperationException(\\\"TODO\\\").\"","checks":["r2","maxCodeLines"]},{"title":"A record or Lombok","why":"On Java 17 the AI may use a record or @Getter, which your course bans.","fix":"Add: \"Plain class, no records, no Lombok.\"","checks":["r1"]},{"title":"Missing the team rules","why":"The AI won't make the class final or copy the list unless told, so callers can change a card's loans.","fix":"Add: \"public final class; this.loans = List.copyOf(loans); getters only.\"","checks":["r0","r1"]},{"title":"Notes and javadoc","why":"The AI adds javadoc for every method and an explanation.","fix":"Add: \"One code block, no comments, no text.\"","checks":["codeBlocks","maxProseWords"]}],"promptHints":[{"label":"Asks for stubs","patterns":["stub","skeleton","UnsupportedOperationException","TODO"]},{"label":"Bans records and Lombok","patterns":["record","lombok"]},{"label":"Asks for a defensive copy","patterns":["copyOf","defensive copy"]},{"label":"Asks for final fields","patterns":["final","private"]},{"label":"Limits the reply","patterns":["no comments","no (text|explanation)","one code block"]}],"hint":"A skeleton is for teammates, so it should have the shape and nothing else. Tell the AI what to leave unimplemented and what your course doesn't allow.","rubricLabels":["Declares cardId, ownerName and loans as private final fields with the UML types, and the constructor stores loans with List.copyOf(loans) (a defensive copy), not a plain assignment","Is declared public final class LibraryCard (not a record, no Lombok), with getCardId(), getOwnerName() and getLoans() and no setters","checkout(Book book) returning boolean and returnBook(Book book) returning void both contain only throw new UnsupportedOperationException(\"TODO\") (no loan-limit logic)"]}