Also you can change your ArrayList name from patient to patientsList or at least patients. Having the class name and variable name same really confuses.
Dustin Schreader wrote:I think I made progress but still no go with error line 7. Cannot find symbol variable next location variable s of type java.util.scanner.
I suspect you didn't read the advice in my post here properly.
You''re still bogged down in the bits and bytes of Java, and I can tell from your code that you're floundering badly.
1. Turn your computer OFF.
2. Sit down with a pencil and paper and describe exactly what you want to do in English.
3. When (and only when) you understand ALL the steps that you want to perform, turn your computer back on and:
4. Read the API documentation for java.util.Scanner, or indeed the Java tutorials, very carefully, and make sure you understand them.
5. Start a new program that follows the steps you described in Step 2.
Right now, you're getting distracted by all sorts of stuff, like try...catch blocks (which you probably don't need; but you'll at least understand a bit better if you've read the tutorials) and how to use Scanner. DON'T. Write a simple, clear program that follows steps you have already described to yourself and understood; you'll find it's a lot easier.
As well as writing what you are doing with a Patient object, also write down the number of List objects you have, when they are created, when they have things added to them, and when they vanish.
Dustin Schreader wrote:Ok I've been doing some reading and found out a little more about generics and arraylists and scanners.
Well I'm afraid you still haven't done enough because
is not only tortured logic, it is not valid Java.
Have you written down the steps you need to do in English, as I suggested? It seems to me that you're still trying to "code your way out of trouble", and that is likely to lead to a long and unrewarding experience with programming.
s.next() returns a String, and only a String; and since the class is final, the only way you will be able to get a Patient out of it is by some form of conversion (of which I see no sign).
I also see that you've now added a Logger before you've even got the rest of your code working, which smacks of existentialism to me. Jean-Paul Sartre may have been a great philosopher, but his ideas belong in books, not in programs.
Dustin Schreader wrote:Netbeans threw the logger automatically since I needed a try catch...
Blimey! Yet another reason (if any more were needed) to avoid using IDEs while you're learning the language.
BTW, I'm not at all convinced that you do need a try...catch block, but I am aware that the tutorials example uses one.
No, don’t go looking for somebody else’s code. Write your own Patient class. Test it by passing Strings to its constructor. Get that working (without using an IDE) and the consider adding it to a List. You will find these things much simpler if you break them down into tiny pieces.
Dustin Schreader wrote:Found a conversion example and slightly modified it.. . .
Now you’ve done that, you have the information in the format you want it, i.e. a Patient. Now you use that Patient object.
Dustin Schreader wrote:The only problem with that is when I want to create an ArrayList<Patient> patientList.... from the CSV file the scanner reads in the arraylist does not except the data from the CSV file because it's a string. I get an error saying cannot find symbol method Patient(java.lang.String).
That means that it can't find a constructor with the signature Patient(String someString). Have you written one? I haven't seen any evidence so far. Perhaps you should show us your entire Patient class.