Home » Java » java – How to correctly write a boolean "if" statement to make letter bold-Exceptionshub

java – How to correctly write a boolean "if" statement to make letter bold-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:
 if(bold){
    setPenWidth(5);  
  } 
   else{
     setPenWidth(1);
  }


  //draw the letter W
public void drawWBold(Color c,boolean bold){
  this.penDown();
  this.setPenColor(c);
  //make the first line:(\) length:100 
  this.turn(-20);
  this.forward(100);
  //make the first middle line(/) length:60
  this.penUp();
  this.backward(100);
  this.penDown();
  this.turn(35);
  this.forward(60);
  //make the second middle line(\) length:60
  this.turn(145);
  this.forward(60);
  //make the second line(/) length:100
  this.turn(-145);
  this.forward(100);
  //move turtle to bottom right of letter area
  this.penUp();
  this.backward(100);
  this.setHeading(90);
  this.forward(50);
  //move turtle to draw next letter
  this.forward(10);
  this.setHeading(0); 
}

For this, I need to create a boolean bold “if” statement. I cannot figure out how to write it correctly. Any help would be appreciated.

I have created letters using Turtles. The bold parameter needs to be able to change line thickness according to a true/false statement. For instance, true if (Color.blue) and false if (Color.red). Can I make a boolean “if” statement using Color properties?

How to&Answers: