This is a very strange and rather specific question.
I end up trying to write a program converter that accepts a java source and converts it so that it doesn't use (by the way)
- Arrays
- Loops
- User Defined Methods
- If statements
This is the difficulty that I set for myself after my teacher told me that it is impossible to write a program without using these things.
I have most of them, including the inlining function and array expansion, however I cannot decide how to control the if statement.
In C ++, I would use labels and gotos and maybe?:, However Java does not support GOTO statements.
My question is this: Given a section of code,
if(CONDITION)
{
}
, , if. , .
, else else if statements.
, , , GOTO, .
:
, ( - , , )
?: . AFAIK void ?: .
IB Computer Science SL, , HL, "" SL, "if" ( 3/15 " ). , - SL, , .
: (By bdares)
String result = (CONDITION)?"0":"A";
try{
Integer.parseInt(result);
//Condition is true
} catch(NumberFormatException e){
//Condition is false
}