
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Practice quiz 2 questions for CMSC 131
Typology: Quizzes
1 / 1
This page cannot be seen from the preview
Don't miss anything!

public class Cabinet { private StringBuffer items; private int totalItems; public Cabinet(String label) { items = new StringBuffer(label); totalItems = 0; } public Cabinet storeItem(String item) { items.append(item); totalItems++; return this; } public String toString() { return "Total: " + totalItems + ", Items: " + items; } } public class Driver { public static void task(Cabinet cab, String item, int cnt) { String f = item + cnt; cab.storeItem(f); cnt = 0;
public static void main(String[] args) { Cabinet cabinet = new Cabinet("office"); String pen = "bluepen"; int many = 2; task(cabinet, pen, many); System.out.println(cabinet); } }
a i n f r a m e t a s k f r a m e