<meta name='google-adsense-platform-account' content='ca-host-pub-1556223355139109'/> <meta name='google-adsense-platform-domain' content='blogspot.com'/> <!-- --><style type="text/css">@import url(https://www.blogger.com/static/v1/v-css/navbar/3334278262-classic.css); div.b-mobile {display:none;} </style> </head> <body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar/820440017588430663?origin\x3dhttp://spirals-in-parentheses.blogspot.com', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

Monday, November 15, 2010

Love is such a gamble In this great big world

Have I already mentioned, Standing In The Hallway has got to be the weirdest Bangles song ever? Well, almost reaching the standards of Waiting For You, Song For A Good Son, and Return Post. That's not to say that it's not good, it's just very un-Bangly. Urk.

Okay I haven't been posting much here because I was re-teaching myself html and CSS, and also playing around with javabat (now officially renamed codingbat). I miss java! But I can't solve the more difficult ones though. That is, those that include weird stuff like i++/count++ and str.substring all in the same part. It gives me headaches. Boolean operators still have the same attraction as they did back when we started java. For some reason double ampersands look a lot better than just one. And ! is the not operator. || is or! && is and! The only thing I have against java (and CSS too for that matter) is that it reads stuff from top bottom so everything has to be in order or else your code is screwed. Ah well. At least logic problems are easier to solve than array (and advanced string) problems. Because all you use in logic is BOOLEAN! And that means no str.substring(str.length()+2, str.length()-3), count++ or anything like that. Also, both arrays and advanced strings involves char and anything with char kills me. Yup, too awesome right?


Example string code:
public String withoutX2(String str) {
if (str.length() < 1)
return str;
if (str.length() < 2 && str.equals("x"))
return ("");
if (str.length() < 3 && str.equals("xx"))
return ("");
if (str.substring(0,2).equals("xx"))
return (str.substring(2));
if (str.substring(0,1).equals("x"))
return (str.substring(1));
if (str.substring(1,2).equals("x"))
return (str.substring(0,1) + str.substring(2));
else
return str;
}


Example logic code:
public boolean squirrelPlay(int temp, boolean isSummer) {
if ((temp > 59 && temp < 91 && !(isSummer))||(temp > 59 && temp < 101 && (isSummer)))
return true;
else
return false;
}


Yes, I wrote both up. Which one looks simpler? Go figure. Also, logic is much, much simpler to understand and to write, which is essential for not cluttering things, because all you need in return is true or false, unlike strings in which the answer is all about str.substring or str.length() or str. True, I could have used || for the string one but that would have made it even more confusing to read.

Of course, there is a cheat method to solve javabat problems if you're trying to debug. (: You can just run it and see what's the problem, then specifically devote a line to it. Another general rule of thumb: if "The left-hand side of an assignment must be a variable" occurs to you then you change whatever it is you're trying to evauluate into a variable, for example, changing
if (b - a = 10)
return true;
to
int ba = b - a;
if (ba == 10)
return true;

I almost sound like I'm promoting logic for java. With the exception that the example for logic is really simple so maybe it isn't fair after all. :/

Posted at 10:44 PM




The What

Hello darkness my old friend. This is a blog. My blog.

The Who

Shermine.
A mostly depressed and disillusioned individual, but may be occasionally high (although that's pretty rare).

The Which

I shall hide the cbox because it's starting to annoy me very much.

The Where

Nope. Singapore, but just nope.

The How

Just in case I ever need extra space.

The When

  • December 2008
  • January 2009
  • February 2009
  • March 2009
  • April 2009
  • May 2009
  • June 2009
  • July 2009
  • August 2009
  • September 2009
  • October 2009
  • November 2009
  • December 2009
  • January 2010
  • February 2010
  • March 2010
  • April 2010
  • May 2010
  • June 2010
  • July 2010
  • August 2010
  • September 2010
  • October 2010
  • November 2010
  • December 2010
  • January 2011
  • February 2011
  • March 2011
  • April 2011
  • May 2011
  • June 2011
  • July 2011
  • August 2011
  • September 2011
  • October 2011
  • November 2011
  • December 2011
  • January 2012
  • February 2012
  • March 2012
  • April 2012
  • May 2012
  • July 2012
  • August 2012
  • September 2012
  • October 2012
  • November 2012
  • December 2012
  • January 2013
  • February 2013
  • March 2013
  • May 2013
  • August 2013
  • December 2013
  • January 2014
  • February 2014
  • March 2014
  • April 2014
  • June 2014
  • July 2014
  • January 2015
  • June 2015
  • September 2015
  • October 2015
  • November 2015
  • January 2016
  • September 2016
  • December 2017
  • August 2020
  • The Why

    Designer: !zrow
    Brushes: toastsnatcher
    Inspiration: threadless