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

Complete the paint method in the given codes to complete the “drawing” of the mo

ID: 3765555 • Letter: C

Question

Complete the paint method in the given codes to complete the “drawing” of the mouth.Use the drawArc method under the Graphics class. In the paint method, you only have to worry about drawing themouth.Codes to draw    the rest of the face are already there. Insert the missing codes please where it said "insert codes".No short cut please like someone answer me earlier. And "also Complete the method public void actionPerformed(ActionEvent e) inside the inner class private class winkfrownRespond implements ActionListener" so when the user press the wink button it will wink and if the user press the frown button it will change thr face.

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ChangingFace extends JFrame{

   //for window
   public static final int WINDOW_LENGTH = 400;
   public static final int WINDOW_WIDTH = 400;
  
   //for face
   public static final int FACE_DIAMETER = 200;
   public static final int X_FACE = 100;
   public static final int Y_FACE = 100;
  
   //for eyes
   public static final int EYE_WIDTH = 20;
   public static final int EYE_HEIGHT = 10;

   public static final int X_RIGHT_EYE = X_FACE + 55;
   public static final int Y_RIGHT_EYE = Y_FACE + 65;
   public static final int X_LEFT_EYE = X_FACE + 130;
   public static final int Y_LEFT_EYE = Y_FACE + 60;

   //for mouth
   public static final int MOUTH_WIDTH = 100;
   public static final int MOUTH_HEIGHT = 50;
   public static final int X_MOUTH = X_FACE + 50;
   public static final int Y_MOUTH = Y_FACE + 100;
   public static final int MOUTH_START_ANGLE = 180;
   public static final int MOUTH_ARC_SWEEP = 180;
  
  
   JButton winkButton;
        JButton frownButton;
        JPanel panel;
  
        private boolean wink;
        private boolean frown;
  
        public ChangingFace()
   {
       super("Changing Face");
      
       setSize(WINDOW_WIDTH, WINDOW_LENGTH);
       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      
      
       getContentPane().setBackground(Color.white);
      
      
       panel = new JPanel();
       winkButton = new JButton("click to wink");
       winkButton.setActionCommand("wink");
       frownButton = new JButton("click to frown");
                frownButton.setActionCommand("frown");
       winkButton.addActionListener(new winkfrownRespond());
       frownButton.addActionListener(new winkfrownRespond());
      
       panel.setLayout(new GridLayout(0,2));
       panel.add(winkButton);
       panel.add(frownButton);
       setLayout(new BorderLayout());
       add(panel,BorderLayout.SOUTH);
       wink = false;
       frown=false;
       setVisible(true);
   }
  
   public void paint(Graphics g)
   {
       super.paint(g);
      
       g.drawOval(X_FACE, Y_FACE, FACE_DIAMETER, FACE_DIAMETER);
       g.fillOval(X_RIGHT_EYE, Y_RIGHT_EYE, EYE_WIDTH, EYE_HEIGHT);
       if(wink == false)
       {
           g.fillOval(X_LEFT_EYE, Y_LEFT_EYE, EYE_WIDTH, EYE_HEIGHT);
           if(frown == false)
           {
              
                                          //insert code here

           }
           else
           {
                          //insert code here

           }
          
          
       }
       else
       {
           if(frown == false)
           {
                          //insert code here
  
           }
           else
           {
                           //insert code here


           }
           g.drawLine(X_LEFT_EYE, Y_LEFT_EYE, X_LEFT_EYE + EYE_WIDTH, Y_LEFT_EYE);
          
       }
      

      
      
   }
  
   private class winkfrownRespond implements ActionListener
   {

       @Override
       public void actionPerformed(ActionEvent e) {
           // TODO Auto-generated method stub
          
          
                       //insert code here

           repaint();
       }
      
   }
  
  
   public static void main(String[] args) {
       // TODO Auto-generated method stub
       ChangingFace face = new ChangingFace();
   }

}

Explanation / Answer

below what i have till now:

package h04PacMan;

import java.awt.*;

public class DrawPacMan {

public void drawPacMan(Graphics g, int x, int y, Color color) {

    g.setColor(color); // set color

    g.fillOval(x, y, 50, 50); // paint

    g.setColor(Color.black);

    g.drawOval(x, y, 50, 50); // outline

    // mouth?

}

public void drawGhost(Graphics g, int x, int y, Color color) {

    g.setColor(color); // color

    // here goes shape

}

}

Example of Mouth-Open Pacman:

g.setColor(Color.yellow);

g.fillArc(0,0,150,150,30,300);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote