Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Need Help with Applet Assignment

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys. I Need some help with this applet assignment.

Here are the instructions:

Create a Java applet file (import javax.swing.JApplet) that has code for drawing at least three graphical images (be creative). The class should extend JApplet and declare a String variable named to hold the shape type.

• In the public void init() method, obtain a parameter value from Run Configurations to determine which of the shapes to draw. Do this by setting your String variable equal to the value returned by the getParameter() method using the argument “shapeType”.
• In the public void paint(Graphics g) method, use if statements to see if your string value for the shape type equals one of the three shapes you define, and then draw the corresponding graphic.
• Below, list the three parameter values you are using for the three shapes. The instructor will run your Java programs by setting the Run Configuration parameter shapeType to each of the three values you list. Each one should cause a different graphic image to be drawn.

You can create interesting images by combining the basic Graphics drawing methods. For example, a stick figure human could be drawn with a circle for the head, eyes, ears, nose and mouth, and lines for the torso, arms, and legs, etc.

Here's the code I have so far:


I'm having trouble with the If Statement, GetParameter, and ShapeType parts. Any help would be best.
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't see any attempt to use them in your code, so what trouble are you having? For example do you not understand what an if statement does or do you not know how to write an if statement or do you not understand why you need one etc etc
 
Master Rancher
Posts: 4510
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

class should extend JApplet and declare a String variable named to hold the shape type.


You seem to have skipped over this requirement for the assignment.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic