Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2-1. Define and implement a class named cart. A cart object represents a horse d

ID: 3709221 • Letter: 2

Question

2-1. Define and implement a class named cart. A cart object represents a horse drawn cart that can seat up to four meerkats, after that meerkats have to walk. The meerkats must be represented by meerkat objects. The cart class has the following constructors and behaviours: cort)i bool addleerkat(meerkat cat); vold enptyCort() void printMeerkats0 // create an erpty cart object // dd, ?"eerkat to the cart, returns false if full // renove all reerkats from the core print the nane, space,the age, then a new line for eech seerkat in the order they were added Your main program should create a cart object and 5 meerkat objects. The cart object is initially empty. Your main program must then add all 5 meerkat objects to the cart object. An appropriate error message must be printed by your main program when the cart is full

Explanation / Answer

{

if (count>5) //check the count

{

m[count+1]=cat.name;

return 1; ///return boolean value

}

else return 0;

}

void emptyCart() //check weather the cart is empty or not

{

if(count==0)

else

}

if (i==0)

System.out.println(" Meerkat added successfully to the cart 1");

else

System.out.println(" Sorry, Something went wrong.");

if (i==0)

System.out.println(" Meerkat added successfully to the cart 1");

else

System.out.println(" Sorry, Something went wrong.");

if (i==0)

System.out.println(" Meerkat added successfully to the cart 1");

else

System.out.println(" Sorry, Something went wrong.");

if (i==0)

System.out.println(" Meerkat added successfully to the cart 1");

else

System.out.println(" Sorry, Something went wrong.");

if (i==0)

System.out.println(" Meerkat added successfully to the cart");

else

System.out.println(" Sorry, Something went wrong.");

OUTPUT:

WELCOME

Meerkat added successfully to the cart 1

Meerkat added successfully to the cart 1

Meerkat added successfully to the cart 1

Meerkat added successfully to the cart 1

Sorry, Something went wrong.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote