Need a java code Create a class called SingleItem This class represents a bag that can hold any single type of object (decided at bag-creation time), and only one item of that type at a time. You may...


Need a java code


Create a class called SingleItem


This class represents a bag that can hold any single type of object (decided at bag-creation time), and only one item of that type at a time. You may have a zero-parameter constructor if you want one, but you must have the following three features:


Add a method called (addItem()) which returns whether or not it was successfully added


Add a method which removes an item from the bag and returns it (deleteAnItem()), return null if there is no item



Add a method to check if an item is in the bag (hasAnIteminTheBag()) which returns true or false



Part 2


Use exception handeling



Write a program (CoconutCherry that This program should accept multiple numbers as command line arguments and print those numbers out again space separated but for multiples of 3 print “coconut” instead of the number, for multiples of 7 print “cherry” instead of the number, and for the multiples of both 3 and 7 print “coconut-cherry” instead of the number. For numbers smaller than 1, print “invalid”

Aug 25, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here