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

this is my code for netbeans got an error so heres the coding: /* * To change th

ID: 3637071 • Letter: T

Question

this is my code for netbeans got an error so heres the coding:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package variables;

/**
*
* @author fishaq
*/
public class DataEntry {
int Id;
String Description = new String();
int Position;
boolean[] ValidExits = new boolean [4];
//1ST PART OF ASSIGNMENT ALL DATA TYPES PLACED IN DATA ENTRY

// THIS IS PART 2 OF ASSGNMENT SET AND GET ASSIGNED TO EVERY FIELD
public void setId(int newIdValue){
Id = newIdValue;
}
public int getId()
{
return Id;
}
// description Set and Get below
public void setDescription(String newDescriptionValue)
{
Description = newDescriptionValue;
}
public String getDescription()
{
return Description;
}
// position get and set below
public void setPosition(int newPositionValue)
{
Position = newPositionValue;
}
public int getPosition()
{
return Position;
}
// boolean get and set below
public void setValidExits (boolean [] newValidExitsValue)
{
ValidExits = newValidExitsValue;
}
public boolean [] getValidExits()
{
return ValidExits;
}

void setValidExits(int i, boolean b) {
throw new UnsupportedOperationException("Not yet implemented");
}



}



and the other coding for second page
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package variables;

/**
*
* @author fishaq
*/
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here

DataEntry Variable = new DataEntry();
DataEntry anotherOne = new DataEntry();
DataEntry Third = new DataEntry();
DataEntry Final = new DataEntry();

// Sets and prints Id variable for Varialbe
Variable.setId(123);
System.out.println(Variable.getId());


anotherOne.setDescription("Please Move Over");
System.out.println(anotherOne.getDescription());

// Sets and Prints the position varialbe for third.
Third.setPosition(56);
System.out.println(Third.getPosition());

// Sets and Prints the ValidExits varialbe for final.
Final.setValidExits(0, true);
Final.setValidExits(1, false);
Final.setValidExits(2, true);
Final.setValidExits(3, true);
System.out.println(Final.getValidExits()[0]);
System.out.println(Final.getValidExits()[1]);
System.out.println(Final.getValidExits()[2]);
System.out.println(Final.getValidExits()[3]);


}

}

i get this error:

run:
123
Exception in thread "main" java.lang.UnsupportedOperationException: Not yet implemented
Please Move Over
56
at variables.DataEntry.setValidExits(DataEntry.java:56)
at variables.Main.main(Main.java:38)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

please can you tell me ho to crrect it

thank u

Explanation / Answer

Hi, the error message says it all. I just ran your program with netbeans myself to double check and, true enough, the "setValidExits" used in the Main method after the comment " // Sets and Prints the ValidExits varialbe for final " is not implemented yet.

If you go back to your DataEntry class, you'll find 2 versions of the same method, one is implemented, the other one throws an "unsupportedOperationException".

Just go to the bottom of your DataEntry class, you'll see this version is implemented with the array argument:

public void setValidExits(boolean[] newValidExitsValue) {
        ValidExits = newValidExitsValue;
    }

but this version with 2 arguments is not:

void setValidExits(int i, boolean b) {
        throw new UnsupportedOperationException("Not yet implemented");
    }

and this second one is the one being called in the main execution method. Implement it and remove the "throw exception" line and you're golden.

I hope this helps, please remember to rate :)))