The Light Panel class contains the instance variable panel which is a two-dimensional array containing integer...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The Light Panel class contains the instance variable panel which is a two-dimensional array containing integer values that represent the state of lights on a grid. The two-dimensional array may be of any size. Lights may be on, off, or in an error state. The instance variable on value represents an integer value for the on state of a light. The instance variable of fValue represents an integer value for the off state of a light. The onValue and offValue instance variables may be of any valid integer value. Any other integer value in the panel array represents an error state for a light. (9 points) Here is the partially completed Light Panel class: public class Light Panel { private int ( ) ( )] panel; private int onValue; private int offValue; public LightPanel (int () () p, int on, int off) { panel=p; onValue = on; offValue = off; } public boolean isColumnError (int column) { //returns true if the column contains 1 or more lights in error //returns false if the column has no error lights //to be implemented in part a } public void fixError () { // to be implemented in part b } //there may be other instance variables, constructors, and methods not shown } Given the example for the panel array below: 3 3 8 8 8 3 4 8 0 3 80 For this example, onValue = 8, offValue = 3 and all other values are errors. There are five array elements with the onValue of 8, thus there are five lights on. There are four array elements with the off value of 3, thus there are four lights off. There are three array elements with other values, thus there are three locations on the panel with errors. Part A: The Boolean method is ColumnError takes an integer parameter for a column of panel and determines if there exists a light in an error state for that column. The method returns true if one or more lights of the column are in an error state and returns false if there are no lights in an error state. Thus a call to isColumnError (0) would return true because column 0 contains a light with an error value of 4 because it is not on(8) or off(3). A call to isColumnError (1) returns false because all lights in column 1 are either on(8) or off(3). Write the is ColumnError method below: //precondition: panel, onValue and off value have been initialized //postcondition: method returns true if col of the panel array contains one or more lights in an error state and false if col of the panel array has no lights in an error state. public boolean is ColumnError (int col) { Part B: The fixError method will repair any column of panel containing an error state. Any column of panel containing an error state will copy the contents of the column immediately to the right of it (note that this column may also contain errors). If the last column on the right contains an error state, it will copy the contents of the first column on the left. For example, given the panel array with contents: 3 3 8 8 8 3 0 3 4 8 8 0 For this example, onValue = 8 and offValue = 3; A call to fixError () would result in the following modification to the panel array: 3 3 8 8 8 3 0 3 0 4 8 8 The first column contains 3, 8, 4 where 4 is an error state so the contents of the second column are copied over. 3 3 8 8 3 3 0 3 8 8 80 The second column contains 3, 3, 8 which has no errors, so no changes are made. The third column contains 8, 0, 8 where 0 is an error state so the contents of the third column are copied over. 3 3 8 3 8 3 3 3 8 800 Notice the third column still contains an error that will not be fixed. The last column contains 8, 3, 0 where O is an error state. So, the contents of the first column (which was modified in the first step) are copied to the last column. 3 3 8 3 3 3 3 3 8 8 0 8 The above array is the final value of the panel array after the call to fixError ( ) completes. Write the fixError( ) method below. Public void fixError( ) { } The Light Panel class contains the instance variable panel which is a two-dimensional array containing integer values that represent the state of lights on a grid. The two-dimensional array may be of any size. Lights may be on, off, or in an error state. The instance variable on value represents an integer value for the on state of a light. The instance variable of fValue represents an integer value for the off state of a light. The onValue and offValue instance variables may be of any valid integer value. Any other integer value in the panel array represents an error state for a light. (9 points) Here is the partially completed Light Panel class: public class Light Panel { private int ( ) ( )] panel; private int onValue; private int offValue; public LightPanel (int () () p, int on, int off) { panel=p; onValue = on; offValue = off; } public boolean isColumnError (int column) { //returns true if the column contains 1 or more lights in error //returns false if the column has no error lights //to be implemented in part a } public void fixError () { // to be implemented in part b } //there may be other instance variables, constructors, and methods not shown } Given the example for the panel array below: 3 3 8 8 8 3 4 8 0 3 80 For this example, onValue = 8, offValue = 3 and all other values are errors. There are five array elements with the onValue of 8, thus there are five lights on. There are four array elements with the off value of 3, thus there are four lights off. There are three array elements with other values, thus there are three locations on the panel with errors. Part A: The Boolean method is ColumnError takes an integer parameter for a column of panel and determines if there exists a light in an error state for that column. The method returns true if one or more lights of the column are in an error state and returns false if there are no lights in an error state. Thus a call to isColumnError (0) would return true because column 0 contains a light with an error value of 4 because it is not on(8) or off(3). A call to isColumnError (1) returns false because all lights in column 1 are either on(8) or off(3). Write the is ColumnError method below: //precondition: panel, onValue and off value have been initialized //postcondition: method returns true if col of the panel array contains one or more lights in an error state and false if col of the panel array has no lights in an error state. public boolean is ColumnError (int col) { Part B: The fixError method will repair any column of panel containing an error state. Any column of panel containing an error state will copy the contents of the column immediately to the right of it (note that this column may also contain errors). If the last column on the right contains an error state, it will copy the contents of the first column on the left. For example, given the panel array with contents: 3 3 8 8 8 3 0 3 4 8 8 0 For this example, onValue = 8 and offValue = 3; A call to fixError () would result in the following modification to the panel array: 3 3 8 8 8 3 0 3 0 4 8 8 The first column contains 3, 8, 4 where 4 is an error state so the contents of the second column are copied over. 3 3 8 8 3 3 0 3 8 8 80 The second column contains 3, 3, 8 which has no errors, so no changes are made. The third column contains 8, 0, 8 where 0 is an error state so the contents of the third column are copied over. 3 3 8 3 8 3 3 3 8 800 Notice the third column still contains an error that will not be fixed. The last column contains 8, 3, 0 where O is an error state. So, the contents of the first column (which was modified in the first step) are copied to the last column. 3 3 8 3 3 3 3 3 8 8 0 8 The above array is the final value of the panel array after the call to fixError ( ) completes. Write the fixError( ) method below. Public void fixError( ) { } The Light Panel class contains the instance variable panel which is a two-dimensional array containing integer values that represent the state of lights on a grid. The two-dimensional array may be of any size. Lights may be on, off, or in an error state. The instance variable on value represents an integer value for the on state of a light. The instance variable of fValue represents an integer value for the off state of a light. The onValue and offValue instance variables may be of any valid integer value. Any other integer value in the panel array represents an error state for a light. (9 points) Here is the partially completed Light Panel class: public class Light Panel { private int ( ) ( )] panel; private int onValue; private int offValue; public LightPanel (int () () p, int on, int off) { panel=p; onValue = on; offValue = off; } public boolean isColumnError (int column) { //returns true if the column contains 1 or more lights in error //returns false if the column has no error lights //to be implemented in part a } public void fixError () { // to be implemented in part b } //there may be other instance variables, constructors, and methods not shown } Given the example for the panel array below: 3 3 8 8 8 3 4 8 0 3 80 For this example, onValue = 8, offValue = 3 and all other values are errors. There are five array elements with the onValue of 8, thus there are five lights on. There are four array elements with the off value of 3, thus there are four lights off. There are three array elements with other values, thus there are three locations on the panel with errors. Part A: The Boolean method is ColumnError takes an integer parameter for a column of panel and determines if there exists a light in an error state for that column. The method returns true if one or more lights of the column are in an error state and returns false if there are no lights in an error state. Thus a call to isColumnError (0) would return true because column 0 contains a light with an error value of 4 because it is not on(8) or off(3). A call to isColumnError (1) returns false because all lights in column 1 are either on(8) or off(3). Write the is ColumnError method below: //precondition: panel, onValue and off value have been initialized //postcondition: method returns true if col of the panel array contains one or more lights in an error state and false if col of the panel array has no lights in an error state. public boolean is ColumnError (int col) { Part B: The fixError method will repair any column of panel containing an error state. Any column of panel containing an error state will copy the contents of the column immediately to the right of it (note that this column may also contain errors). If the last column on the right contains an error state, it will copy the contents of the first column on the left. For example, given the panel array with contents: 3 3 8 8 8 3 0 3 4 8 8 0 For this example, onValue = 8 and offValue = 3; A call to fixError () would result in the following modification to the panel array: 3 3 8 8 8 3 0 3 0 4 8 8 The first column contains 3, 8, 4 where 4 is an error state so the contents of the second column are copied over. 3 3 8 8 3 3 0 3 8 8 80 The second column contains 3, 3, 8 which has no errors, so no changes are made. The third column contains 8, 0, 8 where 0 is an error state so the contents of the third column are copied over. 3 3 8 3 8 3 3 3 8 800 Notice the third column still contains an error that will not be fixed. The last column contains 8, 3, 0 where O is an error state. So, the contents of the first column (which was modified in the first step) are copied to the last column. 3 3 8 3 3 3 3 3 8 8 0 8 The above array is the final value of the panel array after the call to fixError ( ) completes. Write the fixError( ) method below. Public void fixError( ) { } The Light Panel class contains the instance variable panel which is a two-dimensional array containing integer values that represent the state of lights on a grid. The two-dimensional array may be of any size. Lights may be on, off, or in an error state. The instance variable on value represents an integer value for the on state of a light. The instance variable of fValue represents an integer value for the off state of a light. The onValue and offValue instance variables may be of any valid integer value. Any other integer value in the panel array represents an error state for a light. (9 points) Here is the partially completed Light Panel class: public class Light Panel { private int ( ) ( )] panel; private int onValue; private int offValue; public LightPanel (int () () p, int on, int off) { panel=p; onValue = on; offValue = off; } public boolean isColumnError (int column) { //returns true if the column contains 1 or more lights in error //returns false if the column has no error lights //to be implemented in part a } public void fixError () { // to be implemented in part b } //there may be other instance variables, constructors, and methods not shown } Given the example for the panel array below: 3 3 8 8 8 3 4 8 0 3 80 For this example, onValue = 8, offValue = 3 and all other values are errors. There are five array elements with the onValue of 8, thus there are five lights on. There are four array elements with the off value of 3, thus there are four lights off. There are three array elements with other values, thus there are three locations on the panel with errors. Part A: The Boolean method is ColumnError takes an integer parameter for a column of panel and determines if there exists a light in an error state for that column. The method returns true if one or more lights of the column are in an error state and returns false if there are no lights in an error state. Thus a call to isColumnError (0) would return true because column 0 contains a light with an error value of 4 because it is not on(8) or off(3). A call to isColumnError (1) returns false because all lights in column 1 are either on(8) or off(3). Write the is ColumnError method below: //precondition: panel, onValue and off value have been initialized //postcondition: method returns true if col of the panel array contains one or more lights in an error state and false if col of the panel array has no lights in an error state. public boolean is ColumnError (int col) { Part B: The fixError method will repair any column of panel containing an error state. Any column of panel containing an error state will copy the contents of the column immediately to the right of it (note that this column may also contain errors). If the last column on the right contains an error state, it will copy the contents of the first column on the left. For example, given the panel array with contents: 3 3 8 8 8 3 0 3 4 8 8 0 For this example, onValue = 8 and offValue = 3; A call to fixError () would result in the following modification to the panel array: 3 3 8 8 8 3 0 3 0 4 8 8 The first column contains 3, 8, 4 where 4 is an error state so the contents of the second column are copied over. 3 3 8 8 3 3 0 3 8 8 80 The second column contains 3, 3, 8 which has no errors, so no changes are made. The third column contains 8, 0, 8 where 0 is an error state so the contents of the third column are copied over. 3 3 8 3 8 3 3 3 8 800 Notice the third column still contains an error that will not be fixed. The last column contains 8, 3, 0 where O is an error state. So, the contents of the first column (which was modified in the first step) are copied to the last column. 3 3 8 3 3 3 3 3 8 8 0 8 The above array is the final value of the panel array after the call to fixError ( ) completes. Write the fixError( ) method below. Public void fixError( ) { }
Expert Answer:
Answer rating: 100% (QA)
Part A java public boolean isColumnErrorint col for int i 0 i panellength i if panelicol onValue pan... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
What are the advantages and disadvantages of Qantass international cooperative alliances? The Qantas Group maintained its strong position in the Australian domestic market in 2016/17. Through a dual...
-
The Slate Company manufactures and sells television sets. Its assembly division (AD) buys television screens from the screen division (SD) and assembles the TV sets. The SD, which is operating at...
-
Find the derivative of the following functions. p(x) = 8x
-
Harold Fail owned a plot of land in Georgia known as Ebenezer Landing, where he operated a public boat ramp and parking lot. In 1999, Fail and Steve Bodiford entered into an oral agreement...
-
On January 1, 2015, Casey Corporation exchanged $3,300,000 cash for 100 percent of the outstanding voting stock of Kennedy Corporation. Casey plans to maintain Kennedy as a wholly owned subsidiary...
-
A spherical beach pebble is completely submerged under sea water of mass density (not weight density!) 1041 kg/m3. The water exerts an upward buoyant force of magnitude 181 N on the pebble. What is...
-
Hentzel Landscaping commenced its business on January 1, 2017. 1. During the first year of its operations, Hentzel purchased supplies in the amount of $12,000 (debited to Supplies inventory), and of...
-
8. Following is the abridged Balance Sheet of Ganesha Limited: Balance Sheet as on 31-3-2013 Liabilities Share Capital Profit and Loss Account Current Liabilities Assets 1,00,000 Land and Buildings...
-
Trent is a 67-year-old widower. His net income on Line 23600 is $45,000, of which $20,000 is a prior work pension. How much can he claim for the Pension Income amount?
-
x-x-42=0 Rewrite the equation in factored form. = = 0 (Factor completely.)
-
Write a memorandum to the controller comparing and contrasting the two methods (percentage-of-accounts-receivable balance vs. percentage of sales). Recommend the method you think Gold should use, and...
-
Joel de Paris, Inc. Balance Sheet Beginning Balance Ending Balance Assets Cash $ 133,000 $ 129,000 Accounts receivable 331,000 475,000 Inventory 565,000 485,000 Plant and equipment, net 891,000...
-
in forecasting business figures for the coming year, Ling- Poi's owner is including planned purchases of $22000, and an initial markup percentage of 53%. What is Ling-Poi's cost of purchases figure?
-
Use Multisim to design a Logical Unit with 4bits Operation and 4bits for A, B and Z - 4 switches for A - 4 switches for B - 2 switches for Selection bits - 4 LEDs for Z This topic involves the ALU or...
-
Write a paper about the Working relationship in the organization- collaboration within and outside the organization
-
Develop an algorithm for a simple game of guessing at a secret five-digit code. When the user enters a guess at the code, the program returns two values: the number of digits in the guess that are in...
-
Create a JavaFx application that draws a pattern of evenly spaced circles. Use four constants to control the pattern: the number of circles to draw, the radius of the first circle, the change in the...
-
Practice Program 5.4 asked you to define a Trivia class that contained strings representing a trivia question and answer to that question. Add an integer for the number of points that the question is...
-
Describe the car you, a friend, or family member had at age 20. a. What were the top two reasons this car was bought? b. What was the trigger for this purchase?
-
What do these stores do specifically to target you and people with similar needs (i.e., marketing)?
-
Describe the car you, a friend, or family member had at age 30. a. What were the top two reasons this car was bought? b. What was the trigger for this purchase?
Study smarter with the SolutionInn App