• Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in DNA CHAIN

    It does work - there's another bug in your code somewhere. Just to prove it here's an example that works (I'm not suggesting you copy this, your teacher will realise …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in DNA CHAIN

    If you have done that translation then all you need to do the search is is longDNA.indexOf(shortDNATranslated) https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#indexOf-java.lang.String-
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in DNA CHAIN

    I find that code very hard to read, but looking at the matching around line 78 it looks like you are testing if the chars from the two DNA strings …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Marked Solved Status for Generating a triangular random

    I'm looking for an algorithm, pseudocode or any langauge, to generate random numbers with the following characteristics: integer values in the range 0-n lower values much more likely to happen …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Generating a triangular random

    I like where this is going. To explain a bit more of the background (without violating an NDA) this is a mutli-player game situation in which a large number many …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Generating a triangular random

    Excellent! Thank you very much! Yes, I realise the probability formula I posted wasn't quite right, but I was just trying to illustrate a point, so I coudn't be bothered …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in while multiple condition help

    I would say, for while loops if the loop depends on a number of things being true (eg more data waiting, no errors found, server available), then AND is needed
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Generating a triangular random

    OK, strictly speaking I should call it a FIMLTBFO queue - First In, Most Likely To Be First Out queue
  • Member Avatar for JamesCherrill
    JamesCherrill

    Edited Generating a triangular random

    I'm looking for an algorithm, pseudocode or any langauge, to generate random numbers with the following characteristics: integer values in the range 0-n lower values much more likely to happen …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Created Generating a triangular random

    I'm looking for an algorithm, pseudocode or any langauge, to generate random numbers with the following characteristics: integer values in the range 0-n lower values much more likely to happen …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Help With Java Method Calling 2

    Yes, that's the same arror as before. I explained it 3 posts ago.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Help With Java Method Calling 2

    The whole point of making and using a new instance is to avoid static. The "Java" way to do it is to get rid of all the `static` keywords (except …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Help With Java Method Calling 2

    You already asked that in your previous thread, and I already answered it.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Help Calling Java Methods from different classes

    I see from your new thread that you made all your members static. Just be aware that although this fixes this particular problem, it's completely the wrong way to do …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Help With Java Method Calling 2

    OK, I didn't read all the rest of the code after I saw the problem. Anyway... > "getProductList" should... Use the CollectionStorageFileUtility's "load" method to load the Product class collection... …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Help With Java Method Calling 2

    It looks like the line causingthe error is line 71 above products=(List<Product>) CollectionFileStorageUtility.load(Product.class); I don't have any info on CollectionFileStorageUtility, but it seems to return a `Collection`. In this particular …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    OK. now that's done I want to show you one more thing. Your code mixes program logic with GUI and makes both of them confusing. I just did a cut/paste …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    Well done! Are we finished here now? J
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    > is that because it gets cleared out just after the message is entered? Yes, I expect so. That's a good example of why you should keep logic and GUI …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Help Calling Java Methods from different classes

    It's the inventory application class that needs an instance of InventoryManager to work with. I don't understand your second question.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    How you have it now looks OK to me. The compiler is just doing its job! If you declare a method as returning something then the copmpiler checks that you …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    That's a null pointer exception, so that presumably starts when you return null from `getSentenceContaining`. getMatchedSentence tries to loop through all the Strings in that returned value, which is obviously …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    Yes, that's right. (Equally you could have created an inner class to do the same thing.) When the user edits, it's the insert and removes that will mainly be called. …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Help Calling Java Methods from different classes

    You first need to create an instance of InventoryManager - once you have an actual instance then you can do all the following operations using that instance. eg InventoryManager myManager …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Edited help in solving mathematical problem in c program

    <Complete copy of assignment deleted by moderator> Do ensure you own the intellectual property rights to everything that you post Do not post copyright-infringing material
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in help in solving mathematical problem in c program

    OK, so you have copied your teachers complete assignment and posted it on a public web site (did you have the copyright owner's permission?). You didn't even bother to explain …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in How to add button in row in jTable

    Have a look at Oracle's detailed tutorial on JTables http://docs.oracle.com/javase/tutorial/uiswing/components/table.html in the section on Custom Renderers you will learn how to replace cells in the table with the controls of …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    No mouse or key listeners. Just a `DocumentListener`. As in `inputField.getDocument().addDocumentListener(..` Yes, you start with an empty field. The user types "H", the document listener's insertUpdate method is called, you …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    The document listener will be called whenever the user changes the contents of the entry field, reagrdless of how he did it. Personally I am 100% in favour of "live …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    Oops, sorry about the for loop. I created that code by editing yours and forgot to fix the for clause. The GUI stuff is going in the right direction. I …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    Yes, except after the `return null` you don't need to use an else clause, so lines 5 and 9 can be deleted and lines 6-8 indented less, leaving the code …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in does set store elements in specific order ?

    OK yes. The "specific order" can be defined by a comparison function (Java `SortedSet`, C++ `Set`) or by remembering the order/position of elements as they are added (Java `List`), which …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in I need to find out why my income tax output is outputting zero

    I'm sorry, but lines 26-32 are complete nonsense. Just delete them and start again by doing the following: 1. Keep a copy of the requirements in front of you at …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    That looks OK. If you're interested I have a few very small suggestions: 1. As always - naming. eg `searchWord` really means `getSentencesContaining(String s)`. eg `instanceFound` sounds like a boolean …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Random Numbers

    You also have a problem on line 25. As soon as this is executed it will return from the current method - which is the `main` method, so your program …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in does set store elements in specific order ?

    As you say, in Java Set is an interface for Collections with no duplicates but no information about ordering, so that's completely different from C++ sets which are weakly ordered. …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in java.lang.NullPointerException: Attempt to invoke virtual method 'java.uti

    You didn't say which of the many JSONConverter implementations you are using, and the line numbers in your posted code don't correspond to the exception message, but at a guess …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Reading file and store it into 2D array and parse it

    Read this thread - it contains a complete discussion. If you are still stuck start a new thread of your own, and post what you have done so far. Nobody …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in I am trying to run batch script in Jenkins client machine, but not succeede

    1. Use ProcessBuilder, which is the more recent replacement for Runtime exec 2. Parse the args yourself and pass then separately to ProcessBuilder, because its default parsing of command and …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in calculate the grades for a student using if..else statements.

    No. People here will help you if you want to learn. Nobody will do it for you. If you are willing to show effort start a new thread and show …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in logical operators applied to a double

    You can create a class (see previous post) and have a searchable List of those standard sizes, something like class ThreadSize { final double diameter, pitch; final String designation; public …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in logical operators applied to a double

    Looking at that code it seems to be crying out for some Object Oriented love, Why not create a Thread class with pitch, diameter as attributes and methods like `getDesignation()`(with …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Gave Reputation to Mar. Na. in How calculate CBO coupling between objects in java

    package javaapplication12; import java.io.*; import java.util.*; import com.sun.org.apache.bcel.internal.classfile.ClassParser; import com.sun.org.apache.bcel.internal.classfile.JavaClass; import com.sun.org.apache.bcel.internal.classfile.*; import com.sun.org.apache.bcel.internal.generic.*; import com.sun.org.apache.bcel.internal.Repository; import com.sun.org.apache.bcel.internal.Constants; import com.sun.org.apache.bcel.internal.util.*; import com.sun.org.apache.xalan.internal.xsltc.compiler.Parser; import com.sun.xml.internal.ws.org.objectweb.asm.MethodVisitor; import java.lang.reflect.Modifier; public class CyclomaticComplexity { …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in logical operators applied to a double

    Ditto. If all the values are held to 2 decimal places then consider using int variables in units of 1/100. (ie replace float 1.55 with int 155). Then, and only …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    Yes. Create new List<String>, add all the matching sentences to it, and return it.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    Well yes, you can update the GUI directly from inside the search method. However it's best practice to separate GUI from logic, and to keep methods as simple and local …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    OK, excellent! I suggest you try a couple more tests before moving on - just to be sure - change the keyword to (1) a value that is not prersent …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    You can call the search method from anywhere anytime after allSentences has been initialised. To avoid that NPE you could start your print method by testing for `allSentences == null` …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    Like the doc says - isReadable gives you the right answer at the instant you call it, but there's no guarantee the file will still be there and readable when …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    I would not try to move on until I was ure the data is what it should be. I don't know how to interpret that output since I can't see …

The End.