Hey all
I was wondering if there was any way to have a constructor take a variable with an ambigious type and check its type via if statment. Here’s the pseudo of what I mean:
drawStuff(Graphics g, Type s){
c;
if(s.getType==Canvas){
c.setType(s)
}elseif(s.getType==Window){
c.setType(s)
}else{print.out(‘unrecognized type’)}
//draw stuff using c}
I guess I could pass in a string with ‘Canvas’ or ‘window’ and check that with the if statement but I as wondering if there was a built in way of doing this that is maybe a little more efficient.
Thanks in advance