Log in

View Full Version : A quick java script for you all to use for the purpose of addition!



Agnostic Bear
08-02-2011, 12:52 PM
Hey guys I'm just starting to get into the professional Java scene and I wrote this quick java script for you to all use when you need to do addition :)!



$numberOne = 1;
$numberTwo = 2;

class Addition
{
function __construct()
{
$true = true;
$false = false;

// make REALLy sure our variables are correct!!!!!
for( $i = 0; $i < 200; $i++ ) {
if( $true !== true ) {
exit( 'OH NO' );
}
if( $false !== false ) {
exit( 'OH NO' );
}
}
}

function addTwoNumbersTogetherButMakeSureTheyAreNotAnArrayF irst( $numberOne, $numberTwo )
{

$numberOneCheck = new ArrayBuilder();
$numberTwoCheck = new ArrayBuilder();

if( $numberOneCheck->hiFunctionPleaseMakeSureThisIsAnIntegerAndNotAnArr ayWeWouldntWantAnyAccidentsNowWouldWe( $numberOne ) === 'NO IT IS NOT AN INTEGER' )
{ exit( 'AAAAAAAARGH IT IS NOT A NUMBER' ); }

if( $numberTwoCheck->hiFunctionPleaseMakeSureThisIsAnIntegerAndNotAnArr ayWeWouldntWantAnyAccidentsNowWouldWe( $numberTwo ) === 'NO IT IS NOT AN INTEGER' )
{ exit( 'AAAAAAAARGH IT IS NOT A NUMBER' ); }

$numberOne = (int)$numberOne;
$numberTwo = (int)$numberTwo;

$newResult = $numberOne + $numberTwo;
$newResult = (int)$newResult;

if( ((int)$newResult - ((int)$numberOne + (int)$numberTwo)) === (int)0 ) {
return (string)$newResult;
}
}
}

class ArrayBuilder
{
function __construct()
{
$true = true;
$false = false;

// make REALLy sure our variables are correct!!!!!
for( $i = 0; $i < 200; $i++ ) {
if( $true !== true ) {
exit( 'OH NO' );
}
if( $false !== false ) {
exit( 'OH NO' );
}
}
}

function parseArray( $incoming )
{
if( $this->makeReallySureTheThingComingInIsActuallyAnArray( $incoming ) !== true ) {
exit( 'OH NO IT\'S NOT REALLY AN ARRAY :(' );
}

// ok let's just make sure it isn't really trying to hdie
if( $this->makeReallySureTheThingComingInIsActuallyAnArray( $incoming ) !== true ) {
exit( 'haha you thought you could catch me out you cannot i have found out you are not an array mr. not array!!!' );
}

$count = count( $incoming );
$count = ($count + ($count - $count)) + 1; // ok we have added 1.

return reset( $incoming );
}

function hiFunctionPleaseMakeSureThisIsAnIntegerAndNotAnArr ayWeWouldntWantAnyAccidentsNowWouldWe( $incoming )
{
if (is_array($incoming)) return "NO IT IS NOT AN INTEGER";
if (is_bool($incoming)) return "NO IT IS NOT AN INTEGER";
if (is_callable($incoming)) return "NO IT IS NOT AN INTEGER";
if (is_float($incoming)) return "NO IT IS NOT AN INTEGER";
if (is_int($incoming)) return "YES IT IS AN INTEGER";
if (is_null($incoming)) return "NO IT IS NOT AN INTEGER";
if (is_numeric($incoming)) return "NO IT IS NOT AN INTEGER";
if (is_object($incoming)) return "NO IT IS NOT AN INTEGER";
if (is_resource($incoming)) return "NO IT IS NOT AN INTEGER";
if (is_string($incoming)) return "NO IT IS NOT AN INTEGER";

exit( 'I DON\'T KNOW WHAT IT IS' );
}

function makeReallySureTheThingComingInIsActuallyAnArray( $incoming )
{
for( $i = 0; $i < 200; $i++ ) {
if( is_array( $incoming ) === true ) {
// Hmm it might be! let's make sure!
if( is_bool( $incoming ) === false ) {
if( is_callable( $incoming ) === false ) {
if( is_double( $incoming ) === false ) {
if( is_float( $incoming ) === false ) {
if( is_int( $incoming ) === false ) {
if( is_integer( $incoming ) === false ) {
if( is_long( $incoming ) === false ) {
if( is_null( $incoming ) === false ) {
if( is_numeric( $incoming ) === false ) {
if( is_object( $incoming ) === false ) {
if( is_real( $incoming ) === false ) {
if( is_resource( $incoming ) === false ) {
if( is_scalar( $incoming ) === false ) {
if( is_string( $incoming ) === false ) {
// ok we cool
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
}

return true;
}
}

$num[ 1 ] = new ArrayBuilder();
$num[ 2 ] = new ArrayBuilder();

$theNumber[ 1 ] = $num[ 1 ]->parseArray( array(
$numberOne
) );
$theNumber[ 2 ] = $num[ 2 ]->parseArray( array(
$numberTwo
) );

$addition = new Addition();

$addition->addTwoNumbersTogetherButMakeSureTheyAreNotAnArrayF irst( (int)(integer)$theNumber[1], (int)(integer)$theNumber[2] );

// oops i frogt to assign it a value!
$newAddition = new Addition();
$theEndValue = $newAddition->addTwoNumbersTogetherButMakeSureTheyAreNotAnArrayF irst( (int)(integer)$theNumber[1], (int)(integer)$theNumber[2] );


echo $theEndValue . ' IS THE NUMBER YOU WANTED TO FIND BY ADDITION';

exit(01189998819991197253);

Edited by HotelUser (Forum Super Moderator): Thread moved from "Technology Discussion".

Dentafrice
12-02-2011, 02:34 PM
That's PHP... PHP... not Java.

Agnostic Bear
12-02-2011, 04:51 PM
That's PHP... PHP... not Java.
i AM soary but i know javer i have done it for at least 6 years i know how to make java codes thanks!

Dentafrice
12-02-2011, 05:16 PM
Mhmmm.. where's exit come from then? :o

HotelUser
13-02-2011, 04:23 PM
Hey guys I'm just starting to get into the professional Java scene and I wrote this quick java script for you to all use when you need to do addition :)!



$numberOne = 1;
$numberTwo = 2;

class Addition
{
function __construct()
{
$true = true;
$false = false;

// make REALLy sure our variables are correct!!!!!
for( $i = 0; $i < 200; $i++ ) {
if( $true !== true ) {
exit( 'OH NO' );
}
if( $false !== false ) {
exit( 'OH NO' );
}
}
}

function addTwoNumbersTogetherButMakeSureTheyAreNotAnArrayF irst( $numberOne, $numberTwo )
{

$numberOneCheck = new ArrayBuilder();
$numberTwoCheck = new ArrayBuilder();

if( $numberOneCheck->hiFunctionPleaseMakeSureThisIsAnIntegerAndNotAnArr ayWeWouldntWantAnyAccidentsNowWouldWe( $numberOne ) === 'NO IT IS NOT AN INTEGER' )
{ exit( 'AAAAAAAARGH IT IS NOT A NUMBER' ); }

if( $numberTwoCheck->hiFunctionPleaseMakeSureThisIsAnIntegerAndNotAnArr ayWeWouldntWantAnyAccidentsNowWouldWe( $numberTwo ) === 'NO IT IS NOT AN INTEGER' )
{ exit( 'AAAAAAAARGH IT IS NOT A NUMBER' ); }

$numberOne = (int)$numberOne;
$numberTwo = (int)$numberTwo;

$newResult = $numberOne + $numberTwo;
$newResult = (int)$newResult;

if( ((int)$newResult - ((int)$numberOne + (int)$numberTwo)) === (int)0 ) {
return (string)$newResult;
}
}
}

class ArrayBuilder
{
function __construct()
{
$true = true;
$false = false;

// make REALLy sure our variables are correct!!!!!
for( $i = 0; $i < 200; $i++ ) {
if( $true !== true ) {
exit( 'OH NO' );
}
if( $false !== false ) {
exit( 'OH NO' );
}
}
}

function parseArray( $incoming )
{
if( $this->makeReallySureTheThingComingInIsActuallyAnArray( $incoming ) !== true ) {
exit( 'OH NO IT\'S NOT REALLY AN ARRAY :(' );
}

// ok let's just make sure it isn't really trying to hdie
if( $this->makeReallySureTheThingComingInIsActuallyAnArray( $incoming ) !== true ) {
exit( 'haha you thought you could catch me out you cannot i have found out you are not an array mr. not array!!!' );
}

$count = count( $incoming );
$count = ($count + ($count - $count)) + 1; // ok we have added 1.

return reset( $incoming );
}

function hiFunctionPleaseMakeSureThisIsAnIntegerAndNotAnArr ayWeWouldntWantAnyAccidentsNowWouldWe( $incoming )
{
if (is_array($incoming)) return "NO IT IS NOT AN INTEGER";
if (is_bool($incoming)) return "NO IT IS NOT AN INTEGER";
if (is_callable($incoming)) return "NO IT IS NOT AN INTEGER";
if (is_float($incoming)) return "NO IT IS NOT AN INTEGER";
if (is_int($incoming)) return "YES IT IS AN INTEGER";
if (is_null($incoming)) return "NO IT IS NOT AN INTEGER";
if (is_numeric($incoming)) return "NO IT IS NOT AN INTEGER";
if (is_object($incoming)) return "NO IT IS NOT AN INTEGER";
if (is_resource($incoming)) return "NO IT IS NOT AN INTEGER";
if (is_string($incoming)) return "NO IT IS NOT AN INTEGER";

exit( 'I DON\'T KNOW WHAT IT IS' );
}

function makeReallySureTheThingComingInIsActuallyAnArray( $incoming )
{
for( $i = 0; $i < 200; $i++ ) {
if( is_array( $incoming ) === true ) {
// Hmm it might be! let's make sure!
if( is_bool( $incoming ) === false ) {
if( is_callable( $incoming ) === false ) {
if( is_double( $incoming ) === false ) {
if( is_float( $incoming ) === false ) {
if( is_int( $incoming ) === false ) {
if( is_integer( $incoming ) === false ) {
if( is_long( $incoming ) === false ) {
if( is_null( $incoming ) === false ) {
if( is_numeric( $incoming ) === false ) {
if( is_object( $incoming ) === false ) {
if( is_real( $incoming ) === false ) {
if( is_resource( $incoming ) === false ) {
if( is_scalar( $incoming ) === false ) {
if( is_string( $incoming ) === false ) {
// ok we cool
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
} else { exit( 'OH NO' ); }
}

return true;
}
}

$num[ 1 ] = new ArrayBuilder();
$num[ 2 ] = new ArrayBuilder();

$theNumber[ 1 ] = $num[ 1 ]->parseArray( array(
$numberOne
) );
$theNumber[ 2 ] = $num[ 2 ]->parseArray( array(
$numberTwo
) );

$addition = new Addition();

$addition->addTwoNumbersTogetherButMakeSureTheyAreNotAnArrayF irst( (int)(integer)$theNumber[1], (int)(integer)$theNumber[2] );

// oops i frogt to assign it a value!
$newAddition = new Addition();
$theEndValue = $newAddition->addTwoNumbersTogetherButMakeSureTheyAreNotAnArrayF irst( (int)(integer)$theNumber[1], (int)(integer)$theNumber[2] );


echo $theEndValue . ' IS THE NUMBER YOU WANTED TO FIND BY ADDITION';

exit(01189998819991197253);

Edited by HotelUser (Forum Super Moderator): Thread moved from "Technology Discussion".


That's PHP... PHP... not Java.

Whole thing ruined :)

Stephen
13-02-2011, 05:51 PM
nice bit of java skills you've got there. Don't listen to the other guys

Dentafrice
13-02-2011, 05:53 PM
Hahahaa, I think I get it now.. I've got the flu so I was knocked out on meds yesterday.. I'm guessing he's trying to say how much work it takes in Java to do oneee simple task.. gotya haha.

Myy bad.

Stephen
13-02-2011, 07:23 PM
grr now my trolling attempt sounds pointless

Jin
14-02-2011, 09:37 AM
Loving the new emergency telephone number.
http://www.youtube.com/watch?v=RK4Xye7AErE

Chippiewill
15-02-2011, 11:11 PM
Loving the new emergency telephone number.
http://www.youtube.com/watch?v=RK4Xye7AErE
118 999...

How was that relevant? Am I not getting a joke or something?

Agnostic Bear
17-02-2011, 09:27 PM
118 999...

How was that relevant? Am I not getting a joke or something?

No, you're not reading.

N!ck
17-02-2011, 11:16 PM
Thank you so much for this, I have implemented it everywhere I can and it really is very quick :). Can you make me one for division please?

Stephen
18-02-2011, 01:50 AM
no offence but why did this actually get moved to design and development? I know it's like a joke thing but it might be abit misleading to some people who don't get it and actually are looking to learn java

Recursion
18-02-2011, 07:57 AM
Loving the new emergency telephone number.
http://www.youtube.com/watch?v=RK4Xye7AErE

OH LOL. Reread the OP, now I see...

Chippiewill
18-02-2011, 11:44 PM
No, you're not reading.
Apologies for my inability to read, I just really wasn't bothered about the pointless code.

Jin
19-02-2011, 12:04 AM
Apologies for my inability to read, I just really wasn't bothered about the pointless code.
No instead you were bothered about what you believed to be a pointless post. Totally makes sense...

Want to hide these adverts? Register an account for free!