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

*********Please fill out the following code: public class Candidate { It is an e

ID: 3793730 • Letter: #

Question


*********Please fill out the following code:

public class Candidate {

It is an election year on planet Galax. Candidates have given their positions on three issues: whether they support a spaceship tax, want more space exploration, and think Java is the coolest programming language. Using the following program, create the Candidate class that it uses: public static void main (String [] args) {Candidate c1 = new Candidate(true. true, false): Candidate c2 = new Candidate(false. false, true): Candidate c3 = new Candidate(false. true, false): System.out println("ls c1 for the spaceship tax?' + C1 isForSpaceshipTax())://getter System.out.printin("ls c2 for space exploration? " + c2.isForSpaceExploration()); System out-println (" Is c3 for Java? * + c3.isForJava()): System.outprintln("lt seems c3 is having a change of heart."); c3.setJavaPosition(true): System.outprintln("ls c3 for Java now?" + c3.isForJava()); Candidate (] running = {c1, c2. c3}: for (Candidate c: running) {System.out.println(c);//prints torSpaceshipTax true} torSpaceExpiorabon true lor Java false String answer = cl hasSameSpaceshipTaxPosition(c2) ? "Yes": "No"; System.out println("Do candidates c1 and c2 have the same position" + "regarding the spaceship tax?' + answer):}

Explanation / Answer

public class Candidate {

   private boolean tax;

   private boolean explo;

   private boolean java;

   public Candidate(boolean a,boolean b,boolean c){

       tax=a;

       explo=b;

       java=c;

   }

   public boolean isForSpaceshipTax()

   {

       return tax;

   }

   public boolean isForSpaceExploration(){

       return explo;

   }

   public boolean isForJava(){

       return java;

   }

   public void setJavaPosition(boolean a){

       java=a;

   }

   @Override

   public String toString(){

       String ans="";

       ans = "ForSpaceshipTax" + tax + " " + "ForSpaceExploration" + explo+ " " + "ForJava" + java;

       return ans;

   }

   public boolean hasSameSpaceShipTaxPosition(Candidate c1){

       return c1.tax==this.tax;

   }

}