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

Create a class called Mechanic with following instance variable and constants (J

ID: 3706497 • Letter: C

Question

Create a class called Mechanic with following instance variable and constants (JAVA):

Have a default constructor that will set cost to 0.

This class three methods : needRepair, howMuch and repair. These methods simulate the functions of a mechanic.

The methods are defined as follows. Complete the method body, as directed by the comments. We will model the Mechanic to be able to work on any Mechanism , which can be anything ( a Car or a Computer)

Explanation / Answer

public class Mechanic { private int cost; public static int TEST_PRICE = 10; public static int REPAIR_PRICE = 50; public Mechanic() { cost = 0; } public boolean needRepair(Mechanism m) { // include TEST_PRICE into the cost; /* call the reportProblem() method for mechanism m. If this Return is greater than 0, then return true, else return false */ cost = TEST_PRICE; if (m.reportProblem() > 0) { return true; } else { return false; } } public void repair(Mechanism m) { //call the reportProblem method for mechanism m /* add to the cost, the value of REPAIR_PRICE * number of Problems returned by the reportProblem() method */ // call the getFixed() method for mechanism m; cost += REPAIR_PRICE * m.reportProblem(); m.getFixed(); } public int howMuch() { // set a variable charge = cost; //set cost = 0; //return charge; int charge = cost; cost = 0; return charge; } }

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