Find my mistake? Smiley face smiling or frowning using boolean

It is supposed to smile when input is true, and frown when false. When true, it smiles, so I guess that works, but then when false, it gives me an oval for a mouth. This tell me that it is smiling and frowning, but I cant figure out why. Here is the main-
   import javax.swing.*;
   import java.awt.*;
     import java.util.*;
    public class SmileyMain extends JApplet
       public void paint(Graphics canvas)
          SmileyClass sm = new SmileyClass();
          String eyeColor = "Black";
          int nose = 1;
          boolean smile = true;
          Scanner keyboard = new Scanner(System.in);
          boolean done = false;
          System.out.println("What eye color would you like? (blue, green, or pink)");
          eyeColor = keyboard.nextLine();
          System.out.println("How big would you like the nose?");
          nose = keyboard.nextInt();
          System.out.println("Would you like the smiley to smile? (true, false)");
          smile = keyboard.nextBoolean();
          sm.drawFace(canvas);
          sm.drawNose(canvas, nose);
          sm.drawEyes(canvas, eyeColor);
          sm.drawMouth(canvas, smile);
   }And here are is the class-
import javax.swing.*;
   import java.awt.*;
   import java.util.*;
    public class SmileyClass extends JApplet
      private static final int FACE_DIAMETER = 200;
      private static final int X_FACE = 100;
      private static final int Y_FACE = 50;
      private static final int EYE_WIDTH = 10;
      private static final int EYE_HEIGHT = 20;
      private static final int X_RIGHT_EYE = 155;
      private static final int Y_RIGHT_EYE = 95;
      private static final int X_LEFT_EYE = 230;
      private static final int Y_LEFT_EYE = Y_RIGHT_EYE;
      private static final int Y_NOSE = 135;
      private static final int MOUTH_WIDTH = 100;
      private static final int MOUTH_HEIGHT = 50;
      private static final int X_MOUTH = 150;
      private static final int Y_MOUTH = 175;
      private static final int MOUTH_DEGREES_SHOWN = 180;
      private int noseDiameter = 10;
      private int xNose = 195;
      private int mouthStartAngle = 180;
        input: boolean smile
        smile is true, Smiley smiles
        smile is false, Smiley frowns
       private void setMouth(boolean smile)
         if(smile)
            mouthStartAngle = 180;
         else
            mouthStartAngle = 0;
        input: Graphics and a String
        set color to the input String
        set color to white if incorrect input
       private void setEyeColor(Graphics canvas, String color)
         if (color.equals("blue"))
            canvas.setColor(Color.BLUE);
            canvas.fillOval(X_RIGHT_EYE, Y_RIGHT_EYE, EYE_WIDTH, EYE_HEIGHT);
            canvas.fillOval(X_LEFT_EYE, Y_LEFT_EYE, EYE_WIDTH, EYE_HEIGHT);
         else if (color.equals("green"))
            canvas.setColor(Color.GREEN);
            canvas.fillOval(X_RIGHT_EYE, Y_RIGHT_EYE, EYE_WIDTH, EYE_HEIGHT);
            canvas.fillOval(X_LEFT_EYE, Y_LEFT_EYE, EYE_WIDTH, EYE_HEIGHT);
         else if (color.equals("pink"))
            canvas.setColor(Color.PINK);
            canvas.fillOval(X_RIGHT_EYE, Y_RIGHT_EYE, EYE_WIDTH, EYE_HEIGHT);
            canvas.fillOval(X_LEFT_EYE, Y_LEFT_EYE, EYE_WIDTH, EYE_HEIGHT);
         else
            canvas.setColor(Color.WHITE);
            canvas.fillOval(X_RIGHT_EYE, Y_RIGHT_EYE, EYE_WIDTH, EYE_HEIGHT);
            canvas.fillOval(X_LEFT_EYE, Y_LEFT_EYE, EYE_WIDTH, EYE_HEIGHT);
        input: an int
        resize nose to the magnification of size as long as the size is in the range [1,4]
        also, centers the nose by changing xNose
       private void setNoseSize(int s)
         if(s < 5 && s > 0)
            noseDiameter = noseDiameter * s;
            xNose = 200 - (noseDiameter / 2);
         else if(s > 4 || s < 0)
            System.out.println("Incompatible nose resize.");
        input: graphics and int
        calls the private method, setNoseSize
        draws the nose
       public void drawNose(Graphics canvas, int size)
         setNoseSize(size);
         canvas.setColor(Color.BLACK);
         canvas.fillOval(xNose, Y_NOSE, noseDiameter, noseDiameter);
        input: graphics and boolean
        calls the private method, setMouth
        draws mouth
       public void drawMouth(Graphics canvas, boolean smile)
             setMouth(smile);
         canvas.setColor(Color.RED);
         canvas.drawArc(X_MOUTH, Y_MOUTH, MOUTH_WIDTH, MOUTH_HEIGHT,
                                mouthStartAngle, MOUTH_DEGREES_SHOWN);
            System.out.println(smile);   
        input: graphics and String
        calls the private method, setEyeColor
        draws the eyes
       public void drawEyes(Graphics canvas, String color)
         setEyeColor(canvas, color);
         canvas.fillOval(X_RIGHT_EYE, Y_RIGHT_EYE, EYE_WIDTH, EYE_HEIGHT);
         canvas.fillOval(X_LEFT_EYE, Y_LEFT_EYE, EYE_WIDTH, EYE_HEIGHT);
        input: graphics
        draws the face
       public void drawFace(Graphics canvas)
         canvas.setColor(Color.YELLOW);
         canvas.fillOval(X_FACE, Y_FACE, FACE_DIAMETER, FACE_DIAMETER);
         canvas.setColor(Color.BLACK);
         canvas.drawOval(X_FACE, Y_FACE, FACE_DIAMETER, FACE_DIAMETER);     
      //Draw eyes:
         canvas.fillOval(X_RIGHT_EYE, Y_RIGHT_EYE, EYE_WIDTH, EYE_HEIGHT);
         canvas.fillOval(X_LEFT_EYE, Y_LEFT_EYE, EYE_WIDTH, EYE_HEIGHT);
           //Draw nose:
         canvas.setColor(Color.BLACK);
         canvas.fillOval(xNose, Y_NOSE, noseDiameter, noseDiameter);
           //Draw mouth:
         canvas.setColor(Color.RED);
         canvas.drawArc(X_MOUTH, Y_MOUTH, MOUTH_WIDTH, MOUTH_HEIGHT,
                                mouthStartAngle, MOUTH_DEGREES_SHOWN);
   }

1) In the SmileyMain.paint() method, you call drawFace()
2) At the end of the drawFace() method, you draw the mouth arc, using the default angle, which is the smile angle.
3) Next in paint(), you call drawMouth()
4) In drawMouth(), you set the mouth angle to the frown angle, then draw another mouth, so you end up with a frown and smile.
Don't draw parts of the face two different ways. Either call drawFace, and have it call the other drawX methods, or just call the drawX methods directly and remove drawFace().

Similar Messages

  • SMS - Sending to numbers not in your address book and inserting smiley faces

    Hi
    I'm new to the world of Blackberry and sorry if this has been posted elsewhere - I've trawled through and can't find anything similiar.
    When composing SMS messages, I can only send to those people who are in my address book as the address book automatically opens when you select compose SMS.
    Obviously there are times when you need to text to numbers not in your address book so how do you do it?
    So far the only solution I have got is to add numbers to my address book and then delete them.  Surely there must be a way you can just enter the number manually when you need to?
    Secondly is there a shortcut on the Blackberry Pearl to insert smiley faces in SMS messages without entering :-) manually?
    Thanks for your help
    Trish
    I love my Blackberry

    You right. I misread. Hitting the SYM key is only for messenger, not for SMS. I didn't anyway to insert emoticons into an SMS message
    If someone has been helpful please consider giving them kudos by clicking the star to the left of their post.
    Remember to resolve your thread by clicking Accepted Solution.

  • Ichat smiley faces in snow leopard

    hey all,
    i searched but couldn't find a topic about this anywhere, so i thought it would be appropriate to make a new post.
    sometime after i installed snow leopard i noticed that smiley faces now appear in the preview bar (like before you view a message, ichat gives the persons name and a little preview of the message) which is great, but then when i look at the message i dont see the actual image version of the emoticon, just the semi colon and parentheses or whatever they sent. hopefully i made this as clear as possible. do any of you know how i could fix this? obviously its not a huge issue but its a bit irritating.
    thanks everyone

    Hi,
    Welcome to the    Discussions
    I am not sure I have it totally.
    Are you saying that when you get a Text Chat Invite - what you can see of the Message may include a Smiley that appears in Picture form but when you open that the Text only shows the text form of that Smiley ?
    Do you have Show Smiley's Off in the iChat View Menu > Messages sub menu ?
    I thinks this may be a quirk between the Invite settings view and the options not to Show Smileys in the Menu mentioned.
    8:16 PM Friday; November 27, 2009
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"

  • Yellow smiley face icon

    Hey guys. I have a BB Curve 9300 and on the top of the screen, next to my notifiers, there's a yellow teardropped shape smiley icon and because the features of the icon is not as defined as the other notifier icons, I suspect it to be a virus. I don't have any unopened notifications and did not subscribe to Yahoo. I'm baffled. A little advice please. Thanks.

    No, it's not a virus. BlackBerrys have never gotten and are not yet susceptible to any virus, you're not the first. I don't understand why users jump to that first off.
    It's a third party application notification of some sort. Since I don't know what third party apps you have installed, I can't say which, but if you'll check each of your apps for a notification or message or alert, I'm sure you'll find it.
    The Yahoo Messenger icon is not tear-drop shaped, but is a round yellow smiley face .
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Smiley Face with star on screen

    I have seen others on this forum with questions about a blue globe on the screen.  I have a yellow smiley face with a star and a 1 beside it on my screen.  Have had 8130 for 7 months and this is the first time I have seen this.

    Hi,
    I got a solution for this issue...
    I too ws getting this icon on my notification bar bt when I ws clicking on this,nothing ws opening up...
    Solution- open "messages"(not the text messages) n there u will find a notification of some application wth the same star sign(in my case it ws tarrot card reader for BB),jst click on tht and if u dnt want tht App installed then jst close it...the star sign will be gone...
    Hope this will help u... :-)
    with regards
    simply abhik...
    Please click "Accept as Solution" if your issue has been solved and to give thanks/appreciation, click thumbs up...
    For BB OS update: http://us.blackberry.com/software/smartphones/update.html
    BB Simulators: http://us.blackberry.com/sites/developers/resources/simulators.html

  • Making a smiley face

    I'm trying to make a smiley face in my text. the normal doesn't change into an actual smiley face, and I can't find it in the fonts. Any help?

    You will need to find an image and place inline in the text. You could download a few from here (control-click and choose 'Download image'):
    You could also Google smileys or emoticons - there are lots available for free, though many of them are animated which of course would be no use to you.

  • Grey screen with smiley face at startup

    Hi all.
    On my son's g3 imac running 9.2 (or maybe 9.?), after trhe startup chimes the screen freezes with a grey screen and a computer icon with a smiley face.
    What does this mean?
    Any ideas on what I can do?
    Thanks for any help,
    Dave

    Well, the smiling face means that the Mac OS operating system was found on the disk. The boot process didn't get too far because soon after you should get the 9.2 logo.
    You might try holding down the shift key after you power on. This will prevent the extensions from being loaded. Perhaps one is bad.
    You could put a 9.2 cd in the machine & boot. Hold down the c key. See if there is some type of file system checker.
    Did your machine come with any diagnostic software? I think mine did. Run it.
    Robert

  • After upgrading to 8, the text message microphone symbol has been replaced by a smiley face.  Where did it go?

    Where is the text message microphone symbol?  I now have a smiley face instead of the symbol.

    The disk folder you're describing sounds a lot like the Windows Favorites folder. That's actually completely independent from Firefox's bookmark storage.
    After your upgrade, did you freshly install Firefox? In that case, the problem might be an incomplete import of your Windows Favorites (IE Favorites) instead of an incomplete recovery of your old Firefox bookmarks.
    To see whether you still have your Firefox bookmarks, in your backup -- for example, the C:\Windows.old\ folder, or a backup on external media -- could you try to track down a folder named '''bookmarkbackups'''. By default, this is hidden folder, so you may need to turn on viewing of hidden files and folders. This article has the steps: [http://windows.microsoft.com/en-us/windows/show-hidden-files].
    Let me know what you find and then I can suggest next steps.

  • Orange light - smiley face on router

    Hi
    I live in br6 and the internet has been down for a couple of hours. Tried all the troubleshooting, but cannot connect and there is an orange smiley face in the router.
    Is there an outage in my postcode - irritatingly the service update page on sky says everything is fine?

    Afternoon and thanks for letting us know about your Sky Broadband issues.
    Not great to see you are receiving an amber internet light - are you still having issues? If so I can see you've done some troubleshooting - can you confirm you've taken all the steps outlined here?
    Thanks,

  • HT1338 I deleted all the files on my "all my file" in the finder by mistake. Can you please help me to get them back

    I DELETED ALL MY THE FILES ON THE "ALL MY FILES IN THE FINDER BY MISTAKE. PLEASE I WILL BE HAPPY IF YOU CAN HELP ME LOCATE THEM. THANK YOU.

    They should still be in the Trash. Click on the Trash icon in the Dock and drag and drop all your deleted items to the Desktop. You'll just have to tidy them away in your own time.

  • I don't find the mistake :(

    i simply don't find the mistake in that code. it's supposed to browse through a folder you specify and then print out all the files, folders (+ the files in there etc.) into a text file (txt or doc). the output in the eclipse console is correct, but the output to the file is not. if i want to write it to a file (txt or doc) it only browses/writes the top level files and folders. contents of subfolders are not witten into the file? so apparently the recursion doesn't work when i write into a file. but why is that?! below my code...
    void browseFolder(String s){
              File destination = new File(s);
              String entries[] = destination.list();
              int i=0;
              try{
                   File textfile = new File(s+"/file.doc");
                   FileWriter writefile = new FileWriter(textfile);
                   BufferedWriter textbuffer = new BufferedWriter(writefile);
                   if (destination.isDirectory()){     
                        while (i<entries.length){
                             File destinationUnterfile = new File(s+"/"+entries);
                             if (destinationUnterfile.isDirectory()){
                                  //to file
                                  textbuffer.write(s+"/"+entries[i]);
                                  textbuffer.newLine();
                                  textbuffer.write("--------------------------------------");
                                  textbuffer.newLine();
                                  textbuffer.newLine();
                                  //to console
                                  System.out.println(" ");
                                  System.out.println(" ");
                                  System.out.println(s+"/"+entries[i]);
                                  System.out.println("--------------------------------------");
                                  browseFolder(s+"/"+entries[i]);
                             }else{
                                  //to file
                                  textbuffer.write("- "+entries[i]);
                                  textbuffer.newLine();
                                  textbuffer.newLine();
                                  //to console
                                  System.out.println("- "+entries[i]);
                             }//end if/else
                             i++;
                        }//end while
                        textbuffer.close();
                   }else{
                        System.out.println("Please specify a folder to browse.");
                   }//end if/else
              }//end try
              catch (IOException e){
                   System.out.println("Error -- " + e.toString());
              }//end catch
         }//end browseFolder

    hm, does it work if i insert a timestamp into the filename? if tried it like that, but it still doesn't work!
    void browseFolder(String s){
              File destination = new File(s);
              String entries[] = destination.list();
              int i=0;
              try{
                   Date dt = new Date();
                   File textfile = new File(s+"\\file"+dt.getTime()+".doc");
                   System.out.println(s+"\\file"+dt.getTime()+".doc");
                   FileWriter writefile = new FileWriter(textfile);
                   BufferedWriter textbuffer = new BufferedWriter(writefile);
                   if (destination.isDirectory()){     
                        while (i<entries.length){
                             //File destinationUnterfile = s+entries;
                             File destinationUnterfile = new File(s+"\\"+entries[i]);
                             if (destinationUnterfile.isDirectory()){
                                  //to file
                                  textbuffer.write(s+"\\"+entries[i]);
                                  textbuffer.newLine();
                                  textbuffer.write("--------------------------------------");
                                  textbuffer.newLine();
                                  textbuffer.newLine();
                                  //to console
                                  System.out.println(" ");
                                  System.out.println(" ");
                                  System.out.println(s+"\\"+entries[i]);
                                  System.out.println("--------------------------------------");
                                  System.out.println(s+"\\"+entries[i]);
                                  browseFolder(s+"\\"+entries[i]);
                             }else{
                                  //to file
                                  textbuffer.write("- "+entries[i]);
                                  textbuffer.newLine();
                                  textbuffer.newLine();
                                  //to console
                                  System.out.println("- "+entries[i]);
                             }//end if/else
                             i++;
                        }//end while
                        textbuffer.close();
                   }else{
                        System.out.println("Please specify a folder to browse.");
                   }//end if/else
              }//end try
              catch (IOException e){
                   System.out.println("Error -- " + e.toString());
              }//end catch
         }//end browseFolder

  • HT3529 where are you smiley faces and symbols for texting on the iphone 5c?

    Where are the smiley faces and symbols for texting?

    On the emoji keyboard. Go to Settings>General>Keyboard>Add Keyboard and select emoji. Then you will have a small globe key near the number key on the left side of the keyboard. This will allow for selecting between the regular keyboard and the emoji keyboard.

  • I have update to iOS 8.1.3, and I cannot open both centers, or use and cancel apps, or the screen change color to gray, or the display do not recognise that I touch it, and more. If I restart it, I find another mistake in next five hours.Help me pls.

    I have update to iOS 8.1.3, and I cannot open both centers, or use and cancel apps, or the screen change color to gray, or the display do not recognise that I touch it, and more. If I restart it, I find another mistake in next five hours. Help me please.
    iOS 8.1.3
    iPhone 5s 32 GB
    CPU 64 bit

    If you have an iPad 1, the max iOS is 5.1.1. For newer iPads, the current iOS is 6.0.1. For the iPad Mini the iOS is 6.0.2. The Settings>General>Software Update only appears if you have iOS 5.0 or higher currently installed.
    iOS 5: Updating your device to iOS 5 or Later
    http://support.apple.com/kb/HT4972
    How to install iOS 6
    http://www.macworld.com/article/2010061/hands-on-with-ios-6-installation.html
    iOS: How to update your iPhone, iPad, or iPod touch
    http://support.apple.com/kb/HT4623
    If you are currently running an iOS lower than 5.0, connect the iPad to the computer, open iTunes. Then select the iPad under the Devices heading on the left, click on the Summary tab and then click on Check for Update.
    Tip - If connected to your computer, you may need to disable your firewall and anitvirus software temporarily.  Then download and install the iOS update. Be sure and backup your iPad before the iOS update. After you update an iPad (except iPad 1) to iOS 6.x, the next update can be installed via wifi (i.e., not connected to your computer).
     Cheers, Tom

  • How do you get smiley faces?

    How do you get smiley faces for your mail? (not ichat)

    You can use Edit-Special Characters and look under Miscellaneous.
    Jim

  • Smiley face icon: what is it?

    a smiley face icon has appeared on my screen above my application icons (right where you get the email notification icon or the icon that shows you've received/missed a call). i've never seen one of these before and can't figure out what it's trying to tell me, though there is a little number '1' showing right next to it. if anyone can tell me what this is, i'd appreciate the help!
    thanks!!

    I am completely computer illiterate, just so you know. So I will tell you exactly what I see.
    When I go to applications and select blackberry messenger the screen comes up;
    Contact List
    Current Conversations
     -none-
    then there are some other lines, but they are covered by a box that says "Please enter your name......."
    There are OK and Cancel buttons but they are not highlighted.  I can highlight them by scrolling to them.
    If I select OK, I get "Your name cannot be empty".  If I select cancel, it sends me back to the Applications menu with Blackberry Messenger, the calculator, Memopad, etc.
    Sorry that I'm just not good at this stuff.
    Phil

Maybe you are looking for