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

Explain jakarta struts framework, Jakarta Struts is open source execution o...

Jakarta Struts is open source execution of MVC (Model-View-Controller) pattern for the development of web based applications. Jakarta Struts is robust architecture and can be used

How to catch multiple exceptions explain with example, How to catch multipl...

How to catch multiple exceptions explain with example? If multiple blocks match the exception type, the first block in which matches the kinds of the exception catches it. pub

List the java class library, list The Java Class Library? Java holds an...

list The Java Class Library? Java holds an extensive library of pre-written classes you can use in your programs. These classes are separated into groups known as packages. Th

Java 2 micro edition - programming for mobile phones, You must design, code...

You must design, code and demonstrate a J2ME program (a program capable of running on mobile telephones) according to the specification given in the next section.  The overall cour

Binary search tree, You will be required to create an ADT for a Binary Sear...

You will be required to create an ADT for a Binary Search Tree (BSTInterface.java). The interface will be implemented as a Binary Search Tree (BST) using a reference based format.

Make changes to an editable pdf form, Make Changes to an Editable PDF Form ...

Make Changes to an Editable PDF Form Project Description: I need for someone who is able to make some changes to PDF forms. Skills required: Data Processing, Data Entry

Java web programming, Write a JSP to display a table that contains factoria...

Write a JSP to display a table that contains factorials for the numbers from 0 to 10,

Program design, GOALS 1.   Use abstract classes in the correct program...

GOALS 1.   Use abstract classes in the correct programming context. 2.   Evaluate and use a variety of data structures. 3.   Design, evaluate and implement efficient alg

Explain the reading documentation for a class in the class, Explain the Rea...

Explain the Reading documentation for a class in the class library For instance, let's suppose you need to use the URL class in the java.net package. Through reading the docume

Program for solving the producer consumer problem, For this assignment we w...

For this assignment we will be solving the producer-consumer problem with a bounded buffer. You are required to implement this assignment in Java. There are three components in thi

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