Suppose you have a program that already contains the line of code: Carton eggs =
ID: 670926 • Letter: S
Question
Suppose you have a program that already contains the line of code:
Carton eggs = new Carton(12);
Suppose the Carton class contains a method with the following description:
int consume(int_numItems)
updates this Carton to indicate that numItems of the contents of the carton have been consumed and returns the number of items remaining in the carton
Write a line of java that updates the "eggs" object to indicate that 3 eggs have been eaten and then stores the number of eggs remaining in the carton in a variable named "left".
Explanation / Answer
Carton eggs = new Carton(12);
int left;
left = eggs.consume(3);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.