Need help writing a recursive method
hello, im having problems with this and its already giving me a headache!!
i have to write a recursive method that receives a parameter n that prints the following:
1
12
123
1234
how would i even begin to do this...im lost
Ernie_9 wrote:
ok i just got a little problem. it prints
and i needed
So its only changing the order it prints it. but where would that be changed? i tried swapping the bottom part where the parameter is modified and the print but it does not workLooks like you are first decrementing the iterator and then incrementing it ....try the other way around
Similar Messages
-
I need help with this recursion method
public boolean findTheExit(int row, int col) {
char[][] array = this.getArray();
boolean escaped = false;
System.out.println("row" + " " + row + " " + "col" + " " + col);
System.out.println(array[row][col]);
System.out.println("escaped" + " " + escaped);
if (possible(row, col)){
System.out.println("possible:" + " " + possible(row,col));
array[row][col] = '.';
if (checkBorder(row, col)){
System.out.println("check border:" + " " + checkBorder(row,col));
escaped = true;
else {
System.out.println();
escaped = findTheExit(row+1, col);
if (escaped == false)
escaped = findTheExit(row, col+1);
else if (escaped == false)
escaped = findTheExit(row-1, col);
else if (escaped == false)
escaped = findTheExit(row, col-1);
if (escaped == true)
array[row][col] = 'O';
return escaped;
}I am having difficulties with this recursion method. What I wanted here is that when :
if escaped = findTheExit(row+1, col); I am having trouble with the following statement:
A base case has been reached, escaped(false) is returned to RP1. The algorithm backtracks to the call where row = 2 and col = 1 and assigns false to escaped.
How do I fix this code?
I know what's wrong with my code now, even though that if
if (possible(row, col))
[/code[
returns false then it will go to if (escaped == false)
escaped = findTheExit(row, col+1);
how do I do this?Okay I think I got the problem here because I already consult with the instructor, he said that by my code now I am not updating my current array if I change one of the values in a specific row and column into '.' . How do I change this so that I can get an update array. He said to me to erase char[][] array = getArray and replace it with the array instance variable in my class. But I don't have an array instance variable in my class. Below is my full code:
public class ObstacleCourse implements ObstacleCourseInterface {
private String file = "";
public ObstacleCourse(String filename) {
file = filename;
public boolean findTheExit(int row, int col) {
boolean escaped = false;
//System.out.println("row" + " " + row + " " + "col" + " " + col);
//System.out.println(array[row][col]);
//System.out.println("escaped" + " " + escaped);
if (possible(row, col)){
//System.out.println("possible:" + " " + possible(row,col) + "\n");
array[row][col] = '.';
if (checkBorder(row, col)){
escaped = true;
else {
escaped = findTheExit(row+1, col);
if (escaped == false)
escaped = findTheExit(row, col+1);
else if (escaped == false)
escaped = findTheExit(row-1, col);
else if (escaped == false)
escaped = findTheExit(row, col-1);
if (escaped == true)
array[row][col] = 'O';
return escaped;
public char[][] getArray() {
char[][] result = null;
try {
Scanner s = new Scanner(new File(file));
int row = 0;
int col = 0;
row = s.nextInt();
col = s.nextInt();
String x = "";
result = new char[row][col];
s.nextLine();
for (int i = 0; i < result.length; i++) {
x = s.nextLine();
for (int j = 0; j < result.length; j++) {
result[i][j] = x.charAt(j);
} catch (Exception e) {
return result;
public int getStartColumn() {
char[][] result = this.getArray();
int columns = -1;
for (int i = 0; i < result.length; i++) {
for (int j = 0; j < result[i].length; j++) {
if (result[i][j] == 'S')
columns = j;
return columns;
public int getStartRow() {
char[][] result = this.getArray();
int row = -1;
for (int i = 0; i < result.length; i++) {
for (int j = 0; j < result[i].length; j++) {
if (result[i][j] == 'S')
row = i;
return row;
public boolean possible(int row, int col) {
boolean result = false;
char[][] array = this.getArray();
if (array[row][col] != '+' && array[row][col] != '.')
result = true;
return result;
public String toString() {
String result = "";
try {
Scanner s = new Scanner(new File(file));
s.nextLine();
while (s.hasNextLine())
result += s.nextLine() + "\n";
} catch (Exception e) {
return result;
public boolean checkBorder(int row, int col) {
char[][] array = this.getArray();
boolean result = false;
int checkRow = 0;
int checkColumns = 0;
try {
Scanner s = new Scanner(new File(file));
checkRow = s.nextInt();
checkColumns = s.nextInt();
} catch (Exception e) {
if ((row + 1 == checkRow || col + 1 == checkColumns) && array[row][col] != '+')
result = true;
return result;
I thought that my problem would be not to read the file using the try and catch everytime in the method. How do I do this?? Do I have to create an array instance variable in my class? -
Need Help with a getText method
Gday all,
I need help with a getText method, i need to extract text from a JTextField. Although this text then needs to converted to a double so that i can multiply a number that i have already specified. As you may of guessed that the text i need to extract already will be in a double format.e.g 0.1 or 0.0000004 etc
Thanks for your help
ps heres what i have already done its not very good though
ToBeConverted.getText();
( need help here)
double amount = (and here)
total = (amount*.621371192);
Converted.setText("= " + total);Double.parseDouble( textField.getText() );
-
Need help writing host program using LabView.
Need help writing host program using LabView.
Hello,
I'm designing a HID device, and I want to write a host program using National Instrument's LabView. NI doesn't have any software support for USB, so I'm trying to write a few C dll files and link them to Call Library Functions. NI has some documentation on how to do this, but it's not exactly easy reading.
I've written a few C console programs (running Win 2K) using the PC host software example for a HID device from John Hyde's book "USB by design", and they run ok. From Hyde's example program, I've written a few functions that use a few API functions each. This makes the main program more streamlined. The functions are; GetHIDPath, OpenHID, GetHIDInfo, Writ
eHID, ReadHIC, and CloseHID. As I mentioned, my main program runs well with these functions.
My strategy is to make dll files from these functions and load them into LabView Call Library Functions. However, I'm having a number of subtle problems in trying to do this. The big problem I'm having now are build errors when I try to build to a dll.
I'm writing this post for a few reasons. First, I'm wondering if there are any LabView programmers who have already written USB HID host programs, and if they could give me some advice. Or, I would be grateful if a LabView or Visual C programmer could help me work out the programming problems that I'm having with my current program. If I get this LabView program working I would be happy to share it. I'm also wondering if there might already be any USB IHD LabView that I could download.
Any help would be appreciated.
Regards, George
George Dorian
Sutter Instruments
51 Digital DR.
Novato, CA 94949
USA
[email protected]
m
(415) 883-0128
FAX (415) 883-0572George may not answer you. He hasn't been online here for almost eight years.
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice -
I need help writing a script that finds the first instance of a paragraph style and then changes it
I need help writing a script that finds the first instance of a paragraph style and then changes it to another paragraph style. I don't necessarily need someone to write the whole thing, by biggest problem is figuring how to find just the first instance of the paragraph style. Any help would be greatly appreciated, thanks!
Hi,
Do you mean first instance of the paragraph style
- in a chosen story;
- on some chosen page in every text frames, looking from its top to the bottom;
- in a entire document, looking from its beginning to the end, including hidden layers, master pages, footnotes etc...?
If story...
You could set app.findTextPreferences.appliedParagraphStyle to your "Style".
Story.findText() gives an array of matches. 1st array's element is a 1st occurence.
so:
Story.findText()[0].appliedParagraphStyle = Style_1;
//==> this will change a paraStyle of 1st occurence of story to "Style_1".
If other cases...
You would need to be more accurate.
rgds -
Need help writing small program!
Hi. I'm learning Java programming, and I need help writing a small program. Please someone help me.
Directions:
Create a program called CerealCompare using an if-then-else structure that obtains the price and number of ounces in a box for two boxes of cereal. The program should then output which box costs less per ounce.class CerealCompare {
public static void main(String[] args) {
// your code goes here
}Hope that helps.
P.S. Java does not have an if-then-else statement. -
Need Help Writing Server side to submit form via API
Hey
I need help writing a serverside application to submit
information via API to a separate server.
I have a client that uses constant contact for email
campaigns. We want to add to her website a form taht submits the
information needed to subscribe to her email list, to constant
contact via API.
FORM.asp :: (i got this one under control)
name
email
and submits to serverside.asp
SERVERSIDE.ASP
In serverside.asp i need to have
the API URL
(https://api.constantcontact.com/0.1/API_AddSiteVisitor.jsp)
username (of the constant contact account)
password (of the constant contact account)
name (submited from form.asp)
email (submitted from form.asp)
redirect URL (confirm.asp)
Can anyone help get me going in the right direction?
i have tried several things i found on the net and just cant
get anyone to work correctly.
One main issue i keep having is that if i get it to submit to
the API url correctly - i get a success code, it doesnt redirect to
the page i am trying to redirect to.
ASP or ASP.NET code would be find.
THANKS
sam> This does require server side programming.
> if you dont know what that is, then you dont know the
answer to my question. I
> know what i need to do - i just dont know HOW to do it.
If you are submitting a form to a script on a remote server,
and letting
that script load content to the browser, YOU have no control
over what it
loads UNLESS there is some command you can send it that it
will understand.
No amount of ASP on your server is going to change what the
remote script
does.
http://www.constantcontact.com/services/api/index.jsp
they only allow their customers to see the instructions for
the API so i
can't search to see IF there is a redirect you can send with
the form info.
But posts on their support board say that there is.
Alan
Adobe Community Expert, dreamweaver
http://www.adobe.com/communities/experts/ -
I have no idea how to go about writing the toString method for this code. I have to print the array that provides the longest sequence. I would appreciate your help.
Here is the code: import java.io.FileReader;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.StringTokenizer;
class Grid
private int [ ][ ] mainGrid;
public Grid( String file ) throws IOException
FileReader fr = new FileReader( file );
Scanner scan = new Scanner( fr );
ArrayList<ArrayList<Integer>> numR = new ArrayList<ArrayList<Integer>>( );
while( scan.hasNextLine( ) )
String line = scan.nextLine( );
StringTokenizer st = new StringTokenizer ( line );
String number;
ArrayList<Integer> numC = new ArrayList<Integer>( );
while( st.hasMoreTokens( ) )
number = st.nextToken( );
int num = Integer.parseInt(number);
numC.add(num);
numR.add( numC );
int height = numR.size();
int width = numR.get( 0 ).size();
mainGrid = new int [height][width];
for(int i = 0; i < height; i++)
for( int j = 0; j < width; i++)
mainGrid [ i ][ j ] = numR.get( i ).get( j );
private class Position
private int row;
private int col;
public Position( int r, int c )
r = row;
c = col;
public List<Position> getAdjacents( )
int lowRow = row != 0 ? row - 1 : 0;
int lowCol = col != 0 ? col - 1 : 0;
int highRow = row != mainGrid.length - 1 ? row + 1 : mainGrid.length - 1;
int highCol = col != mainGrid[ 0 ].length - 1 ? col + 1 : mainGrid[ 0 ].length - 1;
List<Position> result = new ArrayList<Position>( );
for( int r = lowRow; r <= highRow; r++ )
for( int c = lowCol; c <= highCol; c++ )
if( r != row || c != col )
result.add( new Position( r, c ) );
return result;
public boolean equals( Object other )
if( ! ( other instanceof Position ) )
return false;
Position rhs = (Position) other;
return row == rhs.row && col == rhs.col;
public int getValue( )
return mainGrid [ row ][ col ];
public String toString( )
return "(" + row + "," + col + ")";
public Position newPosition( int r , int c )
return new Position( r, c );
// Public driver
public List<Position> getSequence( )
List<Position> sequence = new ArrayList<Position>( );
for( int r = 0; r < mainGrid.length - 1; r++)
for( int c = 0; c < mainGrid[ 0 ].length - 1; c++)
sequence = getSequence( new Position( r, c ));
return sequence;
// Recursive routine
private List<Position> getSequence( Position pos )
List<Position> adj = pos.getAdjacents( );
if( adj.size( ) == 0)
List<Position> seq = new ArrayList<Position>( );
seq.add( pos );
return seq;
List<Position> maxSeq = null;
for( Position p: adj)
List<Position> currentSeq = getSequence( p );
if( currentSeq.size( ) < maxSeq.size( ))
maxSeq = currentSeq;
maxSeq.add( pos );
return maxSeq;
public String toString( )
StringBuffer sb = new StringBuffer( );
return new String( sb );
class MaxSubsequence
public static void main( String [ ] args )
try
System.out.println( new Grid( "numbergrid1.txt" ));
catch( IOException e)
System.err.println( "Error opening file");
}Call your getSequence method from the toString
method. This gives you a List. Take a look at the
methods of List to see how you can iterate
over the list. Then look at the StringBuffer/Builder
class and see how you can add those elements (plus
any other formatting and words) to the final string.ok, i think i may be getting it a bit more. I don't need to use a loop at all?
I can just call the getSequence method, use a toArray to return the sequence and append the sequence to the new string? -
Need help writing a query for following scenario
Hi all, I need some help writing a query for the following case:
One Table : My_Table
Row Count: App 5000
Columns of Interest: AA and BB
Scenario: AA contains some names of which BB contains the corresponding ID. Some
names are appearing more than once with different IDs. For example,
AA BB
Dummy 10
Me 20
Me 30
Me 40
You 70
Me 50
Output needed: I need to write a query that will display only all the repeating names with their corresponding IDs excluding all other records.
I would appreciate any input. ThanksIs it possible to have a records with the same values for AA and BB? Are you interested in these rows or do you only care about rows with the same value of AA and different BB?
With a slight modification of a previous posting you can only select those rows that have distinct values of BB for the same value of AA
WITH t AS (
SELECT 'me' aa, 10 bb FROM dual
UNION ALL
SELECT 'me' aa, 20 bb FROM dual
UNION ALL
SELECT 'you' aa, 30 bb FROM dual
UNION ALL
SELECT 'you' aa, 30 bb FROM dual
SELECT DISTINCT aa, bb
FROM (SELECT aa, bb, COUNT(DISTINCT bb) OVER(PARTITION BY aa) cnt FROM t)
WHERE cnt > 1; -
Need help writing custom Swing JComponent
Hi, I am trying to write my own version of a "comboBox" that does not have a drop-down box, and doesn't have a down-arrow icon on it. What I would really like to do is basically write a class that is a JLabel, but will accept KeyEvents and FocusEvents. Here is an example of exactly what I want, but it is written using an uneditable JTextArea(Hit the up and down arrow Keys to scroll through the options):
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.text.JTextComponent;
import java.awt.event.KeyListener;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.FocusEvent;
import java.awt.Color;
import java.awt.Font;
public class Test implements KeyListener, FocusListener
Color colorBackgroundFocus = new java.awt.Color(240, 240, 240);
Color colorText = new Color(0, 0, 128);
Font fontText = new java.awt.Font("SansSerif", 1, 12);
JTextArea jTextAreaPOPayment;
public static void main(String[] args)
new Test();
* The Constructor for Test
public Test(){
JFrame jFrame = new JFrame("�:o)");
jFrame.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
((JFrame)e.getComponent()).setVisible(false);
((JFrame)e.getComponent()).dispose();
System.exit(0);
jTextAreaPOPayment = new JTextArea();
setUnEditableTextProperties(jTextAreaPOPayment, "jTextAreaPOPayment", "Cash", 60, 15, 10, 10);
jFrame.getContentPane().add(jTextAreaPOPayment);
jFrame.pack();
jFrame.setVisible(true);
* The Following is used to set all the properties for the JTextArea
public void setUnEditableTextProperties(JTextComponent jTextComponent, String stringVariableName, String stringText, int intSizeX, int intSizeY,
int intLocationX, int intLocationY){
jTextComponent.setSize(new java.awt.Dimension(intSizeX, intSizeY));
jTextComponent.setLocation(new java.awt.Point(intLocationX, intLocationY));
jTextComponent.setName(stringVariableName);
jTextComponent.setVisible(true);
jTextComponent.setForeground(colorText);
jTextComponent.setBackground(null);
jTextComponent.setFont(fontText);
jTextComponent.addFocusListener(this);
jTextComponent.addKeyListener(this);
jTextComponent.setEditable(false);
jTextComponent.setText(stringText);
* The Following is used to Cycle the Payment Types
public void cyclePOPayment(boolean booleanUp){
if (jTextAreaPOPayment.getText().compareTo("Cash") == 0)
jTextAreaPOPayment.setText(booleanUp ? "Check" : "Credit");
else if (jTextAreaPOPayment.getText().compareTo("Credit") == 0)
jTextAreaPOPayment.setText(booleanUp ? "Cash" : "Check");
else if (jTextAreaPOPayment.getText().compareTo("Check") == 0)
jTextAreaPOPayment.setText(booleanUp ? "Credit" : "Cash");
* The Following are needed to implement KeyListener Class
public void keyTyped(KeyEvent e) {
public void keyPressed(KeyEvent e) {
if (e.getComponent().getName().compareTo("jTextAreaPOPayment") == 0)
if (e.getKeyText(e.getKeyCode()).equalsIgnoreCase("Up")){
cyclePOPayment(true);
else if (e.getKeyText(e.getKeyCode()).equalsIgnoreCase("Down")){
cyclePOPayment(false);
public void keyReleased(KeyEvent e) {
* The Following is needed to implement FocusListener Class
public void focusGained(FocusEvent e) {
if (e.getComponent().getName().compareTo("jTextAreaPOPayment") == 0){
jTextAreaPOPayment.setBackground(colorBackgroundFocus);
jTextAreaPOPayment.select(-1, 0);
public void focusLost(FocusEvent e) {
if (e.getComponent().getName().compareTo("jTextAreaPOPayment") == 0){
jTextAreaPOPayment.setBackground(null);
}Here is what I tried to do, but I think I need to write the "fireFocusEvent" method?? I read something about tha tsomewhere, but can't find it again. I tried just implementing the focusListener and KeyListener, and that didn't work...Can someone Help me please!!
what I tried:
import javax.swing.JComponent;
import java.awt.event.FocusListener;
import java.awt.event.KeyListener;
import java.awt.event.KeyEvent;
import java.awt.event.FocusEvent;
import java.awt.Graphics;
import java.awt.Dimension;
class ComboJLabel extends JComponent implements FocusListener, KeyListener
String stringText;
// The preferred size of the gauge
int Height = 20;
int Width = 20;
public ComboJLabel(){
this.stringText = "Test";
public ComboJLabel(String stringText){
this.stringText = stringText;
this.addKeyListener(this);
this.addFocusListener(this);
public void keyPressed(KeyEvent e){
System.out.println("KeyPressed");
public void keyTyped(KeyEvent e){
System.out.println("KeyTyped");
public void keyReleased(KeyEvent e){
System.out.println("KeyReleased");
public void focusGained(FocusEvent e){
System.out.println("Focus Gained");
public void focusLost(FocusEvent e){
System.out.println("Focus lost");
public void setText(String stringNewText){
stringText = stringNewText;
public void paint(Graphics g){
g.setColor(java.awt.Color.black);
g.drawString(stringText, 3, 15);
public Dimension getPreferredSize() {
return new Dimension(Width, Height);
public Dimension getMinimumSize() {
return new Dimension(Width, Height);
import javax.swing.JFrame;
class TestComboJLabel
public static void main(String[] args)
JFrame jFrame = new JFrame();
ComboJLabel comboJLabel = new ComboJLabel();
jFrame.getContentPane().add(comboJLabel);
jFrame.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
((JFrame)e.getComponent()).setVisible(false);
((JFrame)e.getComponent()).dispose();
System.exit(0);
jFrame.pack();
jFrame.setVisible(true);
}But that didn't work! If anyone can help, or show me a good site that tells me how to, It would greatly appreciated! Thanks in advanced,
Jeff �:o)Yeah,sorry about the length...If you just grab the first piece of code(that works BTW0, you will see Exactly what I am trying to do...I just don't want to use anything that already exists and Jerry-Rig it...I want to try and create a new JComponent, more as a learning experience than anything else.
But thanks for the response! -
Need help writing Labview Program!!!!!
I have a labview project that needs to be finished. I was not the original creator of the program and the guy who created no longer is involved with the project and I am left to finish it. Could you make the final adjustment so I can turn this into my professor and get the final grade. Thanks! Willing to pay! Negeotiable price!!!!!!!!
Need help completing assignment! Could anyone assist me in this project!
Attachments:
dial tone detection.zip 1253 KB -
I am trying to convert my prcess from DTS to SSIS. I am running this report out of SAP and then using Monarch to put into the correct form, then I am using the DTS to put it into the database on the SQL server. I am able to get all the other info to
move out having so much trouble here to get the plant number. The issuse is that it is on top on the page and it will change when a new plant is needed.
Thanks for any help
I need help wrting a script that will put that 7010 into a cloumn nnamed plant number.To convert from DTS packages to SSIS you can just open the DTS package in a new SSIS project (depends on target SSIS version by using SSDT or BIDS).
The rest is mechanics how the iteration with SAP is done and may be beyond the scope of this forum.
Arthur
MyBlog
Twitter -
Need help writing a method..
Hi, I am new to Java and I have a little problem with this statement:
a soldTickets(int num) method that records the fact that the specified number of tickets have been sold at this booth.
Basically I only wrote this part:
public int soldTickets(int num)
return num;
I wonder if it is correct, if not what value should I return?i don't think tht shud correctly work. u just define a static variable num in the class. and just perform >num++ in the function and when the program executes u will get to know how many tickets r sold after >printing num. if u do this there is no need of any parameter to be passed in the function because u have >already defined it in the class.
Bye ! i hope it works What happen when he want to enter 50 ticket at a time..then using ur code he needs to call that method 50 times.
Sounds like you need a Booth object which has a variable - int totalTicketsSold;
and a method - public void soldTickets(int num)
in the body of the method num is added to totalTicketsSold; public int soldTickets(int num)
totalTicketsSold = totalTicketsSold + num;
return totalTicketsSold;
I think this match ur requirment best... -
Need help with a remove method..
Hello. I'm getting started on a project here to implement a recursive remove method that will remove any number from a list. I was given a test that the method must pass, but I'm having some trouble getting started. This is my second interaction with the idea of recursion and it's a bit difficult for me.
Here is the test I'm writing the method for:
public void testRemove() {
int element=0;
boolean inList = false;
for (int i = -10; i < 11; i++)list.insert(i);
int numElements = list.length();
list.remove(element);
for (int e : list) {
if ( e == element ) inList = true;
assertTrue(!inList && (list.length()==(numElements-1)));
element = -10;
inList = false;
list.remove(element);
for (int e : list) {
if ( e == element ) inList = true;
assertTrue(!inList && (list.length()==(numElements-2)));
element = 10;
inList = false;
list.remove(element);
for (int e : list) {
if ( e == element ) inList = true;
assertTrue(!inList && (list.length()==(numElements-3)));
//does remove work when element's value greater than value of last item in list
element = 20;
inList = false;
list.remove(element);
for (int e : list) {
if ( e == element ) inList = true;
assertTrue(!inList && (list.length()==(numElements-3)));
//does remove work when element's value less than value of first item in list
element = -20;
inList = false;
list.remove(element);
for (int e : list) {
if ( e == element ) inList = true;
assertTrue(!inList && (list.length()==(numElements-3)));
System.out.printf("%s\n", "testRemove " + list.toString());
}Now, clearly I need to test whether or not the number being removed is in the list (too low/too high), but I'm stuck trying to implement this.
If anyone can give me any ideas or direction it would be greatly appreciated.Thanks for the quick reply, from what I had gathered and what you posted I'm starting to see where I need to go from here. I had gotten as far as if list is null return null, and the cod that you posted makes sense, but implementing it into the source code I already have will be troubling for me. The code as you presented it I have no trouble understanding, for example:
if (list.data == data) return list.next;
list.next=remove(list.next, data);Is clear to me, however I don't know how to implement that into my code. This is the code for the insert method:
private Node<ElementType> insertp(Node<ElementType> list, ElementType element) {
if ( (list == null) || ( element.compareTo(list.getElement() ) < 0 ) ) {
// test for insert at head or before current node
Node<ElementType> newNode = new Node<ElementType>(element, null);
newNode.setNext(list);
return newNode;
else if (list.getNext() == null) { // list with one element
Node<ElementType> newNode = new Node<ElementType>(element, null);
list.setNext(newNode); // element goes at end
else if ( element.compareTo(list.getNext().getElement()) < 0 ) { // insert after list
Node<ElementType> newNode = new Node<ElementType>(element, list.getNext());
//newNode.setNext(list.getNext());
list.setNext(newNode);
else {
insertp(list.getNext(), element); // find insertion point
return list;
}I'm still struggling to understand all of the code there. the element.compareTo() and everything. If you (or some one else) can explain to me what is going on with those methods, I may be able to implement it myself. Also, this may be of some use, these are the methods I have available to me:
public class Node<E> {
// Instance variables:
private E element;
private Node<E> next;
/** Creates a node with null references to its element and next node. */
public Node() {
this(null, null);
/** Creates a node with the given element and next node. */
public Node(E e, Node<E> n) {
element = e;
next = n;
// Accessor methods:
public E getElement() {
return element;
public Node<E> getNext() {
return next;
// Modifier methods:
public void setElement(E newElem) {
element = newElem;
public void setNext(Node<E> newNext) {
next = newNext;
public String toString() {
return element.toString();
} -
Need help writing a Java rule in PDF Forms
I have created an invoice for my contractors via "forms", and in turn made each cell either a drop down list or "read only" field so they cannot change the rate of pay, etc. Here is my issue...My first drop down cell is titled "Job Description". When the contractor selects one of the 8 dropdown options within the Job Description field, I would like it to automatically fill in the hourly rate that is associated with that particular job description (or skill). I currently have my "rate" cell as a drop down, and I want to make that a read only, and when you select the A1 position from Job Description, it will populate the "rate" field with the appropriate amount for that A1 rate. I believe this can be done with writing some Java script, but I have never played with Java and I don't really have the time to teach myself. If anyone can help with me a quick tutorial, or even the formula I should use, so that I can just plug and play, that would be super helpful. If this is a time consuming issue, I would be interested in paying someone to do it for me. Thank you!
Hi George,
I was able to copy my data over to a fresh document, and now it works just fine....thank you so much for your insight and help!
I have another question if you have a moment.
I am trying to do a simple calculation of start time and end time for my employees. Do I need to do this via a javascript, and if so, what area in properties of the result field should I copy it to? for the purpose of the script, the fields are as follows:
DataField1 = start time
DataField2 = end time
DataField3 = total time
I would like to use the h:MM tt format for my time fields if possible.
I've attached a link to the file through my dropbox account, and you'll notice that I created three new fields at the top of the invoice just to test the time calculations before i mock up the whole document.
Dropbox - Contractor Invoice Template (1).pdf
Any help you can give me would awesome!
Thank you!!
Maybe you are looking for
-
SAPscript MAIN Window ITEM TEXT Printing in NEXT PAGE
Hi, I need to print the Item Text (Item Description or Column Description) if the Item Values (Lines) goes to the NEXT page in the Form. I have TEXT ELEMENTS defined for ITEM TEXT and ITEM VALUES in the MAIN Window. There is no issue with Printing th
-
How to make a linked report to be shown in a new browser window
I created two portal reports and a dynamic link between them. By clicking on the linked column of the report A (master list), I successfully got to the report B (detail report). The problem I have is that the report B is shown on the same browser win
-
How to ensure file is not binary...
When I allow users to upload files to my server through a servlet, I want to make sure they are only uploading text files. How do I do this? Thanks
-
How to work the adobe reader?
I don't know how I can get the adobe reader so that I can play online.
-
Creating 12 monthly records from 1 recod with 12 data fields
Greetings; I need to generate one record per month from one input record containing 12 monthly quantity fields. Does anyone have an example or document on how to do this? Jim