A meaningless post

I am at home – a mental treatment facility, and I am sitting in a chair with a thosiba laptop on my laps. I feel like I do things concurrently, or maybe consecutively. I don’t know, it is hard to realize what is actually going on.

I have noticed that my mind wanders beyond what’s consider normal. They call it disorganized speech, and I see their logic but I don’t agree with it because I have noticed that when I make statements I seem to be normal, but when I answer questions I see to show what they call mind-wandering. What is that, and why is it not normal?

I like to wander because I like to follow patterns in a given stement until I finally get to what I seem to think is the root of that statement. It’s like trying to reach an infinite light and you get to the point that your mind reachest the strongest pressure that it can mentally hold, and then you stop.

I am done, I’ve given up.

I recall that a few minutes ago a person I met, and a person that happens to believe he was or is my friend – and I don’t know because I don’t trust, started to show interesting behaviour. He appears to be upset, or angry, or just frustrated. I don’t know, but I think it is very insteresting and hilarious. I am trying to remember what he actually said, but I think I will just try to pay attention because he keeps walking back and forth. I can’t quite get it, he voice sounds slightly more comprehensable than a murmur.

He talked to me but I coudn’t comprenhend what he was trying to say. He spared a cig with me and I joined him. While he was talking about drugs, and how if he get hook backed on will have him “tweaking”.

Now I just came back from drinking a Mickie 40 at my nearest park. He is back talking pure B.S. and now I feel that I have to put up with it. I am lightweigth drunk and it makes me wonder if I have a drinking problem. I am only in my 20’s and I’ve drinking for the last two weeks everynight. Around 8:00PM I feel the craving for a beer.  I get a mild feeling of emptyness and isolation. I wonder about the world and the things I do and then I wind up in a concious state of mind that makes me realize how meaningless everything is. I mean, thinking about it is meaningless because no mattter what the end result will be, I will always feel either well enough, or sufficiently sad, or fairly mad. I could be a real cynic and tell  myself that everything will be alright, but I can’t and I probably won’t do that. It is probably because I am living in a powerless situation. Perhaps that’s the reason I look at those who are feeling wonderful and seem to only talk about the good things they happen to have. And then I look at those who are doing bad and have to listen to all the stuff that happens to them.

Draw a crate with Java

In this post we are going to draw a crate. This is a quiz that I had to solve for the course I am taking at Udacity.com; Introduction to programming. Thanks to professor Cay Horstman for making this assigment simple by constructing a simple graphic library that we will be using to solve this problem.

Download the java graphic library here:

Simple graphic library

 

We need to draw the following crate:

Image

Instructions:

// Draw a crate by combining a rectangle with five lines.
//
// The front face is a rectangle with top left corner (20, 30),
// width 100, and height 40.
//
// A diagonal line goes from the face’s top left corner to (50, 10).
// Another diagonal line goes from the face’s bottom right corner
// to (150, 50).
// A third diagonal starts at the face’s top right corner and is
// parallel to the others.
// The fourth and fifth line join the end points of the diagonals.
//
// Before programming, get out a pen and draw the crate on a
// sheet of paper! Label each of the points with their coordinates.
//
// Also, don’t forget to call draw() on your rectangle and line objects.

 

Solution:

public class DrawACrate
{
public static void main(String[] args)
       {
        Rectangle face = new Rectangle(20, 30, 100, 40);
        face.draw();
        Line line1 = new Line(20, 30, 50, 10);
        line1.draw();
        Line line2 = new Line(120, 30, 150, 10);
        line2.draw();
        Line line3 = new Line(50, 10, 150, 10);
        line3.draw();
        Line line4 = new Line(150, 50, 150, 10);
        line4.draw();
        Line line5 = new Line(120, 70, 150, 50);
        line5.draw();
    }
}

You can try it at Udacity: Here

 

Copying strings in Java

This exercise took me awhile to figure out. It is very simple, but what made it harder was the question being asked. I think my best advice is to be very careful about what’s being asked. In this exercise I create two variables, the second variable holds the value of the first variable, then I needed to make the second variable uppercased. 

The code:

String greeting = “Hello, World!”;

String greeting2 = greeting;

System.out.println(greeting2.toUpperCase());

The questions:

What is the value of greeting?

What is the value of greeting2?

Here is a more visual presentation:

Image

 

Compiling and then running the above 3 lines of Java will only returns the current value of greeting2, which is in uppercase because we are calling the toUpperCase() method on greeting2, currently. This is where I got confused, when I ran the code the result was “HELLO, WORLD!” and I was getting it wrong because that’s not what’s being asked.

In order to find out what the answer to the aforementioned questions are, one have to call greeting and greeting2 indepandently, or if you’re smarter than me you can figure it out immediately. 

System.out.println(greeting);

System.out.println(greeting2);

Once we call greeting2 indepent from the toUpperCase() method we get “Hello, World!”, which is the value of the variable greeting (the first variable) and will not return the value uppercased because greeting2 is just a reference to the value of the first variable.

So the answer to both of the obove questions are the same, because on the second question they are asking what’s the value of greeting2 and not what’s the value of greeting2.toUpperCase().

Java replacing a character within a string

For the last few hours I’ve been following up on the Introduction to programming course at Udacity and thought that it my be helpful to review what I’ve been learning so far by writing about it. That’s one of the reasons why I started this blog. I think that writing about what I’m currently self-studying can make learning more efficient.

The Java Replace Method

For this exercise I need to:

Image

Hints that were given:

Go to  the replace() method in the javadoc
Verify your answer using BlueJ
Here is an example method call: birthday.getMonth();

To solve the problem I created a new java file with the following code:

String river = “Mississippi”; // Initialize a string variable

System.out.println(river.replace(“i”, “x”); // Replace the letter “i” with the letter “x” by using the replace method

And finally the keyword String before the variable name (in this case river) declares the return type which is string

The result is: Mxssxssxppx

10 places where anyone can learn to code

I think this is a great list if you are just starting. I have some good resources that I would like to share in a future post.

TED Blog

 

blog_learn_to_code_art_revTeens, tweens and kids are often referred to as “digital natives.” Having grown up with the Internet, smartphones and tablets, they’re often extraordinarily adept at interacting with digital technology. But Mitch Resnick, who spoke at TEDxBeaconStreet, is skeptical of this descriptor. Sure, young people can text and chat and play games, he says, “but that doesn’t really make you fluent.”

[ted_talkteaser id=1657]Fluency, Resnick proposes in this TED Talk, comes not through interacting with new technologies, but through creating them. The former is like reading, while the latter is like writing. He means this figuratively — that creating new technologies, like writing a book, requires creative expression — but also literally: to make new computer programs, you actually must write the code.

The point isn’t to create a generation of programmers, Resnick argues. Rather, it’s that coding is a gateway to broader learning.“When you learn to read…

View original post 568 more words