Why processing an unknown number of parameters, JAVA Programming

Assignment Help:

Why Processing An Unknown Number Of Parameters ?

Most of the time you have a fairly high-quality idea of what parameters will and won't be passed to your applet. Therefore some of the time there will be an undetermined number of parameters. For example Sun's imagemap applet passes each "hot button" as a parameter. Different imagemaps have different numbers of hot buttons. Another applet might need to pass a series of URLs to different sounds to be played in order. Each URL could be passed as a separate parameter.

Or perhaps you need to write an applet in which displays various lines of text. Although it would be possible to cram all this information within one long string, that's not too friendly to authors who need to use your applet on their pages. It's much more sensible to give each line its own PARAM element. If this is the case, you should name the tags thorugh some predictable and numeric scheme. For instance in the text example the by set of PARAM elements would be sensible:

< PARAM name="Line1" value="There once was a man from Japan">
< PARAM name="Line2" value="Whose poetry never would scan">
< PARAM name="Line3" value="When asked reasons why,">
< PARAM name="Line4" value="He replied, with a sigh:">
< PARAM name="Line5" value="I always try to get as many
syllables into the last line as I can.">

The program below displays this limerick. Lines are accumulated within an array of strings called poem. A for loop fills the array along with the various lines of poetry. There are 101 spaces in the array, but since you won't normally required that several, an if clause tests to see whether the attempt to get a parameter was successful through checking to see if the line is null. As soon as one fails, the loop is broken. Once the loop is finished numLines is decremented through one because the last line the loop tried to read was not there.

The paint() method loops through the poem array and prints each String on the screen, incrementing the y position through fifteen pixels each step so you don't draw one line on top of the other.


Related Discussions:- Why processing an unknown number of parameters

Taking in command line arguments, Taking in Command Line Arguments In J...

Taking in Command Line Arguments In Java, the program can be written to accept command-line-arguments. Example Code:  command-line arguments /*  This

I need liferay especialist, I need Liferay Especialist Project Descripti...

I need Liferay Especialist Project Description: We want a JAVA + JSF + Portlets expert Liferay expertise is needed Big Data and Online Tools + Multilingual Portal & Websit

Help, Are you real? I dont want to get help from a computer

Are you real? I dont want to get help from a computer

Draw a use case diagram in uml, Extend the given drawing program (the versi...

Extend the given drawing program (the version that allows undo and redo) as follows: a) Allow the user to select font and font size; user should also be able to boldface, underl

Compression, 1 occurrence of "oog", and 1 occurrence each of "goog", "oogo"...

1 occurrence of "oog", and 1 occurrence each of "goog", "oogo",

Describe about the term access protection, Describe about the term Access P...

Describe about the term Access Protection ? Global variables are a typical cause of bugs in most programming languages. A few unknown function can modify the value of a variabl

What are the basic advantages of jms, JMS is asynchronous in nature. Theref...

JMS is asynchronous in nature. Therefore not all the pieces need to be up all the time for the application to function as a whole. Even if the receiver is down the MOM will kept th

Who can an applet talk to, Who Can an Applet Talk To? By default an app...

Who Can an Applet Talk To? By default an applet can just open network connections to the system from that the applet was downloaded. This system is known as the codebase. An ap

2d world of ants and doodlebugs, We have to create a world class that conta...

We have to create a world class that contains a 2d array then create an abstract class called organism that contains move() method the organism should move randomly one step at the

USES OF JAVA PROGRAMMING, WHY WE USE JAVA IN PROGRAMMING INSTEAD OF OTHER P...

WHY WE USE JAVA IN PROGRAMMING INSTEAD OF OTHER PROGRAMMING LANGUAGE

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd