please write a class Sandwich that has attributes for breadType, base cost, cost per item, and an array list of type str

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

please write a class Sandwich that has attributes for breadType, base cost, cost per item, and an array list of type str

Post by answerhappygod »

please write a class Sandwich that has attributes for breadType, base cost, cost per item, and an array list of type string for items.
Add get methods for all the attributes.
Add an addItem method that accepts a string value of the item to add to the arraylist of items.
add a getTotalCost method that returns the base cost + the cost per item * the number of items in the items array list
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply