Question: Step 1 : Produce correct output Three commented - out lines of code exist in main ( ) . Uncomment the lines and click the

Step 1: Produce correct output
Three commented-out lines of code exist in main(). Uncomment the lines and click the Run button. Verify that the program's output is:
2+2=4
Unknown method: printPlus2
Secret string: abc
Click the "Submit for grading" button to submit your code to the auto-grader. The auto-grader will run two tests against the submitted code: a "Compare output" test and a "Unit test".
The submission will pass the "Compare output" test because the programs output matches the expected output. Passing the test achieves 1 of the 10 possible points.
The "Unit test" fails because the LabPrinter object created in mainO was not used. Steps that follow outline how to use the LabPrinter object to satisfy this lab's requirements and achieve 1010 points
Step 2: Inspect the LabPrinter class
Inspect the LabPrinter class implemented in the LabPrinterjava file Methods print2Plus20 and printSecret0 print strings using System.out.println().
Step 3: Implement callMethodNamed()
Remove the three uncommented lines from main( Then implement the callMethodNamed) method in Main.java to handle three cases:
Step 3: Implement callMethodNamed()
Remove the three uncommented lines from main(). Then implement the callMethodNamed main.java to handle three cases:
If methodName is "print2Plus2", call printer's print2Plus20 method.
If methodName is "printSecret", call printer's printSecret() method.
If methodName is anything other than the two strings mentioned above, print "Unknown method: xyz", where xyz is methodName's value.
After implementing callMethodNamed, click the Run button. Verify that the program's output is, once again:
2+2=4
Unknown method: printPlus2
Secret string: abc
Step 4: Submit code for 1010 points
Once callMethodNamed 0 is properly implemented, submitting the code should receive 10 out of 10 points. The program's output is exactly the same as the implementation from step. But step 3 s implementation uses the LabPrinter object and step 1 does not.
Step 5: Understand the difference
The unit test uses a different implementation of LabPrinter than what's shown in LabPrinter.java. Calls to each method are tracked, so the unit test determines whether or not callMethodNamedn was actually implemented according to lab requirements.
Step 5: Understand the difference
The unit test uses a different implementation of LabPrinter than what's shown in LabPrinter.java. Calls to each method are tracked, so the unit test determines whether or not callMethodNamed) was actually implemented according to lab requirements.
Most labs in this book are similar. Program output matters, but how the output is achieved matters more. Methods to implement will commonly require use of an object passed as an argument.
Run
Main.javaHistoryTutorial
DESKTOPCONSOLE
Step 1 : Produce correct output Three commented -

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!