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:
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
-
The following financial information is available for Bramble Corporation. (in millions) 2025 2024 Average common stockholders' equity $2,500 $2,625 Dividends declared for common stockholders 342 759...
-
4 The foundation of the previous example is now assumed square with dimensions equal to 2x2 m. (i) Calculate an estimate of the average stress increase underneath the foundation at z = 0.5m, 1.0m,...
-
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...
-
Suppose X1 is a numerical variable and X2 is a dummy variable and the regression equation for a sample of n = 20 is a. Interpret the regression coefficient associated with variable X1. b. Interpret...
-
Give examples from this chapter to illustrate how different forms of financial institutions may either grow rapidly or decline as economic and regulatory conditions change.
-
How do patient safety tools become ineffective when employees do not feel free to fully communicate? Healthcare organizations have invested in many tools to promote patient safety, but are they...
-
Pro Fender, which uses a standard cost system, manufactured 20,000 boat fenders during 2016, using 146,000 square feet of extruded vinyl purchased at $1.05 per square foot. Production required 410...
-
Use series to approximate the definite integral to within the indicated accuracy: P 0.4 e Idx, with an error
-
Details of a company's insurance policy are shown below: Premium for year ended 31 March 2008 paid April 2007 Premium for year ending 31 March 2009 paid April 2008 $25,920 $28,800 What figures should...
-
Activity 4.b Using the Expanded Accounting Equation Using the expanded accounting equation, calculate and enter the answers for each question. You will need to use the answers you calculate for...
-
Decide on a culture you identify with and consider yourself a participant. Remember that culture is not just defined as ethnicity and race. You are part of many cultures (military, sports, music,...
-
A company wants to offer stock for sale to the public for the first time. Which other institution is involved in this type of transaction?
-
Consider each of the following costs incurred by a manufacturing business. The business has a raw materials warehouse, a finished goods warehouse, several factories for production and a corporate...
-
Find the reasonable value of the following securities: a) a 10- year plain vanilla coupon bond with a $1,000 par value, a 9% coupon rate, and a YTM of 10% b) a 10 - year plain vanilla zero coupon...
-
Find f'(x) if f(x) = -5x cos x. f'(x) = =
-
Preparing a Classified Balance Sheet from the following accounts, fisted in alphabetical order, prepare a classified balance sheet for Berkly Wholesalers as of December 31, 2013. All accounts have...
-
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...
-
Talias Tutus bought a new sewing machine for $40,000 that will be depreciated using the MACRS depreciation schedule for a 5-year recovery period. a. Find the depreciation charge each year. b. If the...
-
Sec uses 60 000 tons of salt over a 50-week working year. It costs 100 to order salt and delivery follows two weeks later. Storage costs for the salt are expected to be 0.10 per ton per year. The...
-
Calculate the following values assuming a discount rate of 12 per cent: (a) 500 compounded for five years; (b) the present value of 500 to be received in five years time; (c) the present value of 500...
Study smarter with the SolutionInn App