This is just a guess, but it looks like you're not using a parameterized ArrayList, right? So you'll need to cast the result from checklist.get(q) in order to treat it as the class you want. Your class is "parameter", I think, so try this:
This is just a guess, but it looks like you're not using a parameterized ArrayList, right? So you'll need to cast the result from checklist.get(q) in order to treat it as the class you want. Your class is "parameter", I think, so try this:
if (((parameter)checklist.get(q)).type != 1)
Ooh, so this gets the entire object (which is in fact "parameter"). That's the technique I need. Thank you.
Are you familiar with parameterization? That's often a better solution than just casting, as long as you're familiar with the concept.
What you've got right now is an ArrayList which thinks it's storing plain old Objects. This works fine as long as you always remember to cast to the actual class, "parameter", whenever you want to manipulate an item in the list. That's what the "(parameter)" does: casts the Object to the type you want.
Parameterization is the idea of telling the ArrayList that it's not just holding Objects, it's holding something more specific; the way you'd specify this is using angular brackets in the type name, such as ArrayList<Integer> or ArrayList<parameter>. When you reference this parameterized type, the return value from .get(), for example, will be of the type you gave (Integer, parameter, whatever) instead of just Object. That way you don't have to cast it at all; it's already the type you want.
The usual convention in the Java API is to denote parameterized types with the letter 'E', such as in this ArrayList documentation: http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html
Omitting the bracketed type will always default it to Object, I believe.
Saeris on
0
Options
Monkey Ball WarriorA collection of mediocre hatsSeattle, WARegistered Userregular
edited March 2012
Eclipse usually complains if you don't use the generic/parameterized version of something when it exists. Or maybe that's the way I have it set up.
Monkey Ball Warrior on
"I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
Eclipse usually complains if you don't use the generic/parameterized version of something when it exists. Or maybe that's the way I have it set up.
I got the message to stick in (parameter) as said above. I was just hesitant on the meaning.
Furthermore, because my main ArrayList of parameter objects is consistent throughout the program, I decided to just make my second array just a standard array of integers, rather than a second ArrayList. I'll match up the Arraylist index with what's in the integer array as needed. The first ArrayList is still a must.
Actually, if you declare the ArrayList as ArrayList<parameter>, you won't need to cast anything by sticking '(parameter)' in - the rest of your code should just work.
Generics are fun, up until you get bit by type erasure.
(And what's with the class with an all-lowercase name? Your chances of confusing it with a variable are high.)
...If a man wanted to learn Python for shits and giggles where would he start?
e: I think that's what I want to learn next. Once I get this stupid Java certification complete, of course.
baronfelWould you say I havea _plethora_?Registered Userregular
edited April 2012
As I have been tinkering with the ruby koans to pick up that language, you may find the Python koans helpful.
Basically you're provided a slew of source files and you run some entry point test file via the language's interpreter/compiler. It spits out an error message telling you which file to start in, and you investigate that file, which is filled with comments to teach you about the language. You modify that source file to fix the errors, then rerun the entry point to see if you were successful.
Phew my CEO just told me that he wants me to take my time on the Java cert retest so that I pass it. Said the bonus and reimbursement still applies as long as I take it within a month or so.
I don't think all the time in the world would prepare me for it so much as guessing how the JRE thinks.
Oh it won't, but if my friend can get a 61 then so can I. I just cannot stick to reading the book and getting it. I need to do some examples and try out everything.
...If a man wanted to learn Python for shits and giggles where would he start?
e: I think that's what I want to learn next. Once I get this stupid Java certification complete, of course.
So, I got my copy of "The Little Lisper" in the mail over the weekend. I was flipping through it, glancing at the exercises and descriptions. I found, on page 13 in big bold letters "This space reserved for JELLY STAINS". I'm not sure if this is a programming manual or a misprint of the principia discordia. Learning lisp is going to be entertaining.
Okay guys. I need your Google-fu expertise. Can anyone find a good example of wxNotebook ONLY in C++? There will be a few in Python. Also, not the sample: notebook.cpp (because I just need an example of how to make a notebook, and this thing has like 600 lines of code and it is impossible for me to read). (NOTE: wxNotebook is apparently their name for "tabbed panes")
I have scoured the internets with search terms like "wxNotebook example", "wxNotebook example C++", "wxNotebook example C++ -python", etc. I just can't find a simple one that I can build off of.
I don't understand what's going on in that function call. I'm assuming it's return type is a MyGrid? But it doesn't return anything... Is that another Class? (Looks at the .h file...) Yeah, it's another class. Okay so it's a MyGrid class... What about the colon after the parameters?
: wxGrid(parent, wxID_ANY)
Does that mean it's "extending" it? (I'm not even sure if extending exists in C++)
You are looking at the special function form of a constructor.
The : wxGrid(parent, wxID_ANY) is a call to the superclass constructor to handle the base stuff. The code inside the function handles what is different for MyGrid.
That's a constructor ? MyGrid::MyGrid (A::B) is how you say "I'm defining MyGrid in the class MyGrid (defining B in class A)" : wxGrid is the parent class' constructor (I'm assuming MyGrid inherits from wxGrid) and then proceeds to define more data pertinent to it's own definition.
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
You are looking at the special function form of a constructor.
The : wxGrid(parent, wxID_ANY) is a call to the superclass constructor to handle the base stuff. The code inside the function handles what is different for MyGrid.
Okay so it's basically saying super(parent, wxID_ANY) inside the function? (but in C++ terms)
You are looking at the special function form of a constructor.
The : wxGrid(parent, wxID_ANY) is a call to the superclass constructor to handle the base stuff. The code inside the function handles what is different for MyGrid.
Okay so it's basically saying super(parent, wxID_ANY) inside the function? (but in C++ terms)
I know I know... I keep bringing everything back to Java, but that's what I'm most comfortable with for now. I'm hoping to change that. But I get the feeling the longer I stick at a job that exclusively uses Java the longer I'll get stuck doing it because why would you hire someone who's never done Python even if he has more programming experience in another language.
I know I know... I keep bringing everything back to Java, but that's what I'm most comfortable with for now. I'm hoping to change that. But I get the feeling the longer I stick at a job that exclusively uses Java the longer I'll get stuck doing it because why would you hire someone who's never done Python even if he has more programming experience in another language.
Depends on the length of the hire and what you're hiring for. If you want a python guy, by all means, hire someone who is an ace at python. If you're hiring someone for their area expertise (security, databases, encryption, etc) then it becomes more difficult to bias hiring based on known languages.
The only things I need to pass into it are: parent, and ID, right? The rest are defaults? Is it possible to have 5 parameters, 3 defaults set, but one of these defaults are at the beginning... Actually I'll use the above code as an example.
wxNotebook (wxWindow* parent,
wxWindowID id = wxANY_ID,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size,
long style = 0,
const wxString& name = wxNotebookNameStr)
Using the above, if I did something like: wxNotebook *nb = new wxNotebook(panel, wxSize(500,500)), would that work? Would it know that I was using the defaults for everything else?
e: I'm guessing not, since the compiler has no idea what I'm talking about when I do that. But it's worth an ask.
You can only have defaults at the end. You can't have a default parameter followed by a one without a default. You'd see why when you try to actually call the function, as you found out I guess with your edit comment.
You can only have defaults at the end. You can't have a default parameter followed by a one without a default. You'd see why when you try to actually call the function, as you found out I guess with your edit comment.
Crap it must be SQL where you can just use commas then to have it work they way I said. I haven't actively worked with C++ for 5-6 years so and have forgotten a ton.
Posts
Ooh, so this gets the entire object (which is in fact "parameter"). That's the technique I need. Thank you.
What you've got right now is an ArrayList which thinks it's storing plain old Objects. This works fine as long as you always remember to cast to the actual class, "parameter", whenever you want to manipulate an item in the list. That's what the "(parameter)" does: casts the Object to the type you want.
Parameterization is the idea of telling the ArrayList that it's not just holding Objects, it's holding something more specific; the way you'd specify this is using angular brackets in the type name, such as ArrayList<Integer> or ArrayList<parameter>. When you reference this parameterized type, the return value from .get(), for example, will be of the type you gave (Integer, parameter, whatever) instead of just Object. That way you don't have to cast it at all; it's already the type you want.
The usual convention in the Java API is to denote parameterized types with the letter 'E', such as in this ArrayList documentation: http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html
Omitting the bracketed type will always default it to Object, I believe.
I got the message to stick in (parameter) as said above. I was just hesitant on the meaning.
Furthermore, because my main ArrayList of parameter objects is consistent throughout the program, I decided to just make my second array just a standard array of integers, rather than a second ArrayList. I'll match up the Arraylist index with what's in the integer array as needed. The first ArrayList is still a must.
But hot damn is this project getting complicated.
Generics are fun, up until you get bit by type erasure.
(And what's with the class with an all-lowercase name? Your chances of confusing it with a variable are high.)
...If a man wanted to learn Python for shits and giggles where would he start?
e: I think that's what I want to learn next. Once I get this stupid Java certification complete, of course.
http://www.diveintopython.net/ - A python book that I've never actually really read, but it seems popular at least
http://code.google.com/edu/languages/google-python-class/
Basically you're provided a slew of source files and you run some entry point test file via the language's interpreter/compiler. It spits out an error message telling you which file to start in, and you investigate that file, which is filled with comments to teach you about the language. You modify that source file to fix the errors, then rerun the entry point to see if you were successful.
Shame the author went nuts and deleted his entire presence off the Net - that's actually a mirror there.
The official documentation is really good too - I didn't use too much of the tutorials, but the API/modules reference is very robust.
Quite a few people paid for 3 months, so this is a heads up that you'll be wanting to renew if you wish to keep your shell account shortly here.
Thanks.
Oh it won't, but if my friend can get a 61 then so can I. I just cannot stick to reading the book and getting it. I need to do some examples and try out everything.
Programming in Python 3, 2nd ed by Summerfield.
Fuckin' internet.
I have scoured the internets with search terms like "wxNotebook example", "wxNotebook example C++", "wxNotebook example C++ -python", etc. I just can't find a simple one that I can build off of.
I don't understand what's going on in that function call. I'm assuming it's return type is a MyGrid? But it doesn't return anything... Is that another Class? (Looks at the .h file...) Yeah, it's another class. Okay so it's a MyGrid class... What about the colon after the parameters?
: wxGrid(parent, wxID_ANY)
Does that mean it's "extending" it? (I'm not even sure if extending exists in C++)
The : wxGrid(parent, wxID_ANY) is a call to the superclass constructor to handle the base stuff. The code inside the function handles what is different for MyGrid.
Okay so it's basically saying super(parent, wxID_ANY) inside the function? (but in C++ terms)
That is exactly what it is doing yes.
I know I know... I keep bringing everything back to Java, but that's what I'm most comfortable with for now. I'm hoping to change that. But I get the feeling the longer I stick at a job that exclusively uses Java the longer I'll get stuck doing it because why would you hire someone who's never done Python even if he has more programming experience in another language.
Depends on the length of the hire and what you're hiring for. If you want a python guy, by all means, hire someone who is an ace at python. If you're hiring someone for their area expertise (security, databases, encryption, etc) then it becomes more difficult to bias hiring based on known languages.
The only things I need to pass into it are: parent, and ID, right? The rest are defaults? Is it possible to have 5 parameters, 3 defaults set, but one of these defaults are at the beginning... Actually I'll use the above code as an example.
Using the above, if I did something like: wxNotebook *nb = new wxNotebook(panel, wxSize(500,500)), would that work? Would it know that I was using the defaults for everything else?
e: I'm guessing not, since the compiler has no idea what I'm talking about when I do that. But it's worth an ask.
Nintendo ID: Incindium
PSN: IncindiumX
I thought that might be the case. Since if your function takes in two integer parameters, how would it know which is which?
Crap it must be SQL where you can just use commas then to have it work they way I said. I haven't actively worked with C++ for 5-6 years so and have forgotten a ton.
Nintendo ID: Incindium
PSN: IncindiumX