Thursday, 6 November 2014

Java Basics Tutorial 3: Switch Statement



The switch statement

 The switch statement is a wonderful way to reduce code and make code simpler to read and follow.  Let us begin by explaining when a Switch statement would be useful. For example if you had a set of numbers which you needed different results for each. Lets say numbers 1 through 5. Okay there are a couple of ways. An IF statement would do the trick.  Ahhh but a SWITCH statement would do the same with less code and be more readable in the future if extending was required to maybe 1 through 10.

This is how they work.

SWITCH (The condition your testing)
{
   CASE 1: condition 1 is met
   break

   CASE 2: condition 2 is met
   break;

   etc etc....
 
   DEFAULT (a default is set that if no condition is met a result can still be set.)

}


Okay so how does this look in real code? For this example I will do a switch statement on a fictitious game. an imaginary dice throw which certain numbers will let your character move.


switch (dice_roll)
{
   case 1:
   character = "Move left";
   break;

   case 2:
   character = "Move right";
   break;

   case 3:
   character = "Move forward";
   break;

   case 4:
   character = "Move backwards;

   case 5:
   character = "Move down";
   break;

   case 6:
   character = "Move up";
   break;

   default = "Stay still";  

}


Well thats all there is to it. Looks clean and simple doesn't it.  Really handy thing to know and will serve you well in the future. Just remember a switch statement needs to test a condition. Each case returns a result and you should always have a default just in case no condition is met. Simple!




Java Basics Lesson 2: Operators



OPERATORS

An operator is just a way of testing a conditional statement.  To break this down even further an example would be like:

5 < 6.... (the integer 5 is less than the integer 6). The less than sign is the operator!

Okay, pretty simple. We have more operators in Java which make coding a conditional statements very simple.

Other conditionals in Java can test other things. Here are a few:

< less than
> greater than
= equal to
<= less than and equal to
>= greater than and equal to
!= not equal to


++ increment integer by one
-- decrement integer by one
&& AND
|| OR

We generally use operators in programming to test a condition. If a person is a girl or a boy, if your pet at home is a cat or a dog... all of these things can be tested in programming through conditional statements.

How we do this is: (example show how to test what stage of a boys life he is in (String stageofperson))

if (boy_age > 12 && < 18)  //if the boy's age is greater than 12 AND less than 18 he is a teenager
{
   stageofperson = "Teenager";
}
elseif (boy_age >= 18 && < 70) //if the boy's age is greater than or equal to 18 but less than 70 = adult.
{
  stageofperson = "Adult"
}
elseif (boy_age < 12)
{
  stateofperson = "Child"
}
else
{
  stateofperson = "Pensioner"
}


WOW okay thats looks long but actually its not.  We are checking through an if statement to see what stage of the person of life is in. Child if he is less than 12. 13 and above to 18 makes him a teeenager and 18 and over but less than 70 makes him an adult. If none of those match he must be older than 70 which makes him a pensioner.  Seems like a long convoluted way but it actually makes for simple and easy programming and simple to explain here. In real life coding practice we would use a SWITCH statement for the above code. This I will blog next but for the purpose of understanding conditional operators this serves it purpose.

Another example would be this in a WHILE loop. We will to WHILE loops soon...

while (name != "Jenny")
{
   //increment the student number
  student++;

}

Well  hope this has helped. Operators are used in every single program you will make. You will know them soon enough. Do not be daunted by anything here.... it will all come together quickly and soon.




Saturday, 1 November 2014

Java Basics Lesson 1 - Variables and Data Types


All major programming languages use this simple concept, so what you learn here can be taken to almost any modern programming language.

Variables and Literals

Variables are dynamic and can be changed. Variables basically hold data or information. Think of them as  slots in a memory bank.  Variables can be assigned values easily and they hold that data until they are changed or discarded as redundant.

A literal is a fixed type of data (the types of data that can be stored in a variable).  There are four types of literals. These are:


  1. Booleans (True or false)
  2. Characters and Strings (character is a single letter, Strings consist of usually more than one character)
  3. Numbers (Java supports integer, floating point, byte literals)
  4. Nulls (The Null literal is literally what it means...nothing)

Examples of all above:

boolean hairywoman = true;
char initial = p;
String surname = "rabbids";

int integer = 3;
float floating = 3.1467788557757785464434 ; (floats can hold 32 bits of data)
double mega_floating = 3.4e+038; (doubles can contain up to 64 bits of data)
byte byte_literal = 2; (nobody really uses bytes anymore as integers do the same job)


When we are coding we will often need to hold information that a method or part of the program will require to use later. Variables do this efficiently. You can use them in multiple ways to achieve a goal for example.....

int a = 5; 
int b = 3;
int result = a + b;
the result variable now holds an integer 8.... clever stuff!

you could then use a boolean in a loop (we will get to loops later)

if (result == 8 )
{
    boolean answer = true;
}
else
{
   boolean answer = false;

}


Thats all there is to it folks!

Thursday, 23 October 2014

More German advert humour



Another classic advert from Germany.  This one is a fairly old advert but just has always remained in my mind as a classic. Enjoy by clicking the link below or watching it on the youtube insert in the page.





Real leaked court document makes for funny reading.



Somethings you see on the internet and you really and truly are astonished with the stupidity.... this image below is a real document of a conversation in a courtroom between the Judge and a witness whom is a Doctor.

Read the image and try not to laugh as this friggin happened...... Pleased the Doctor saw the funny side, the judge is probably still thinking!


Saturday, 18 October 2014

Choosing an IDE for my Java Application development....


Okay folks, this is a quick post. I have been sitting here for the last day and a half deciding on which IDE I would like to use for creating a small Java Application. I want to write a security program called FileKiller. More on the app later.... For now what were my choices of IDE?

I occasionally code for android and use the Android Studio platform. This platform has come a long way since it's beginning only a year ago. The Android Studio has been coded and ported from the IntelliJ IDEA (www.jetbrains.com) community. I really do like this IDE for Android so I installed it on my Linux laptop without hesitation. Unfortunately it seems for simple Java Swing development it is overly complicated and took a long time to set up to even begin coding.  They also have a unique way and structure in dealing with Java projects that you create. It was not long before I was looking for a quicker more straight forward solution as I am not a heavy developer. I may return to this IDE at a later date.

Everyone knows of Eclipse, Eclipse has been the IDE of choice for multiple programming languages, it is heavily supported and there are a bunch of docs and community aid online.  I have used it before and it's known for having a couple of weird bugs here and there which can be frustrating if you do not know all of them. Thus, you can be looking at fault in your code for days to finally find out that the null pointer exception was a compiler error (might be a poor example but think this has happened to me on several occasions). I also do not like the feel of Eclipse visually or intricate design layout.. So Eclipse is a bit like Marmite. You love it or hate scenario. I am impressed with it...but I don't enjoy to use it.

NetBeans is what I have ended up with. There are others to choose from but it just seemed logical to myself to use a dedicated Java Platform IDE for developing a Java Swing Applications. I have installed it as I did with the other two and found I was rooted into coding my new app instantly. It looks like a basic IDE and it seems to have all the features of both mentioned above for what I am doing, I also managed to get started, designing and coding my app within minutes of installation. I was at least one hour on each other platform before I even started to look at coding. No imports or plugins needed just a raw coding platform with a GUI designer. Simple.  I downloaded the latest version as the one Ubuntu have in their repositories is ancient. Years old.... sort it out Ubuntu. So hats off to my new IDE of choice NETBEANS! You made things easy and I am enjoying coding together my app. Wish I only had more of a clue about Java.  Referencing has become a 3 minute habit.  Brain is fried.



FILE KILLER Alpha .007 in development.

Quick note about File Killer. I will be releasing this app on the GNU public license. The application will take in files that you wish to be terminated from your computer forever. No return, not with the best techs out there. My app will kill that file, and all that ever remained on that part of your HD. Using the choice of pfitzner7, pfitzner33, gutman35, USArmy AR380-19, and DoD 5229.22M security to destroy the files and their locations on your disk.  A real way to destroy info off an HD before you throw it to the trash.  I expect Beta 0.1 will be out in a month and will be posted here!

Sunday, 12 October 2014

Drive Club... worth the wait?


Drive Club is a beautiful game. We have all seen the E3 demo's, read articles in magazines and on the internet as to how brilliant and amazing this game will be even although it has been delayed for a whole year.  The reason for the delays were to perfect the ultimate racing game which encourages multiplayer racing.  So the PlayStation Store finally had a copy of it on their PlayStation Store. I was hooked into the hype so thought nothing about parting with a bargain of £34.99 which was offered as an apology from Sony and the Studios involved for releasing a game which was supposed to be released on the same day as the console first launched. Let me get into the review.....

Beauty and the beast is a good way to describe Drive Club.  It really is amazing how the next gen platform games are coming along graphically.  Drive Club is no exception.  Backgrounds so beautiful you forget to see where the hell your going at 160 MPH. The cars have a level of detail we have not seen in a racing game before.  I have never seen light physics been put to this much of a test before either. Every indicator, paint glissen, or glass reflection has been done with intricate lighting techniques which only a next gen console or PC could handle.  It really is a masterpiece to look at.

What about the Cars and the Tracks? Pretty important in a racing game I would say. Well this is a
mixed bag. The Cars are perfect replicas. You could not tell any details which defect from the real thing. There is a good selection of cars but not hundreds. A few hand picked great cars worth driving. They have modeled them so well I can see why they did not go crazy building lots of cars. To build one of these must have taken forever. So hats off to the developers for this.  The tracks are another story. No real world maps are included. None. Not one. This for me was a massive let down. A huge hole in a racing game. They have made up their own tracks. None of which flow well or give you that technique and feedback making you feel the need to master the road ahead.  The tracks are mainly just sections of road in what they consider exotic locations, Scotland, India, Canada etc.. In those Countries there are a couple racetracks rather than roads. The tracks again are fictitious and lacking. They have no feel of a real racetrack. Poorly designed and I can't see how they will create great racing either. I have driven on them all and none have grabbed me as " a track I gotta improve on".  Okay, so Cars look good and the tracks suck for a dedicated racer.... what's the actual physics like...?


The physics are sadly again on my list of disappointments.  Far too close to an arcade racer, no competition to Forza. Not even competition to Sony's Gran Turismo range. I could put it in the same par as Project Gotham Racing. Personally I think that Project Gotham Racing was better also.  I really do not have a good feeling from the cars. The button mapping can be changed but do not let you use the sticks for accelerating and braking...the real only true way to control a simulator by easing on the brakes and slowly accelerating finding the limit of adhesion. Its trigger pull and trigger snap for braking. The cars waft round corners...sometimes I feel like the track is just going under you and your not actually in any real control of left and right... you just have to turn right when its right... turn left when its left. Okay there is a little more to it than that but it just doesn't cut the mustard. Forza has no rival. It is the only game I miss by leaving Microsoft and going to PlayStation.  So the physics are completely lackluster for a racing game.  The environmental physics on the other hand are great. Real night to day light changes, weather, leaves flying, the smoke from burnt rubber, all of that helps to its authenticity as a racing game but the car and track physics fall to short for the environment physics to overtake the let down.

Damage on the cars is present which is a welcomed addition to these types of games. I know that manufacturers generally do  not like Game Studios adding real world damage physics as they want their car represented in the best possible light. Well Drive Club have managed to somehow get over that with the manufacturers and included a limited damage system. Although I say damage is included we are talking purely aesthetic.  You can drive as fast and as hard as you like into any object without any real threat of anything except for loosing time. Once again very disappointing. Not every person will agree with me here...many find car damage very frustrating which I understand but at least turn damage off. At least have an option. Another let down which makes this game a stupid arcader dressed up to try and be something it will never be.

I am also disappointed with their method of starting a race. No Qualifying, just a random place on the grid which is never pole position.  No lights, not even a countdown, just "READY" and when that disappears, which happens way to soon, the race has begun. Their is no feeling of lining up on a grid, the need for a perfect start, any tactic to be thought about for heading into turn 1... its all just go and lets smash everyone out of the way as I dont even bother to brake for turn one...who cares? no damage, no costly effects, no thrill, no need to race. The more I write the more I hate this game. I am actually getting more and more disappointed as I write.

Well okay it's just a really pretty arcader, but isn't this all about the online elements of the game? Oh
my god...where does one start. The Developers have apologised....... their game doesn't work online yet. Yup.. thats the short of it. Its an online racer which is not working. If you have seen the news they are struggling to maintain their servers and they have all been overwhelmed. Okay... be slightly sympathetic, all games have a bump here and there on release. Battlefield 4 was the biggest bump I ever had hit before. Drive Club takes the biscuit. They have actually had to cancel some parts of the online play until they can fix it. Oh dear, the problem is you can't even get online. The servers are down all the time.  If you do manage to get online... the online racing is no better than any other game. They have taken a new angle to try and build online clans and teams to drive together in. I just cant see how this will hold any value if the game itself is not playable to any standard of a sim. Arcade bashing and crashing offers no skill reward and no reason to be in a team or even try to work together. Their is zero realism so why bother.

Overall what do I think? Sadly this is my let down of the year! or should I say "2 year let down", as thats how long we have waited for this. The driving physics are far too basic, their is no element of this to make it feel like a serious or realistic racer, its an arcade bash about with an online element which isn't strong enough to overcome the poor tracks, design and gameplay. I tell you what it is.... a creation of beauty and light dynamics.  It's the sort of thing I would watch as my computer did a benchmark test. About as fun as well. No replays, no strong driving connection, no roads worth learning and overall a complete waste.  I have driven all morning and afternoon to unlock a few cars, have no real excitement, definitely no heart pumping moments and I am more disappointment than 'an elephant without a trunk in a watering hole'. The short of this means a game with nothing new to offer the next gen. It's an arcade racer that we have all seen before. It is just prettier. No new concepts.  I think I would have accepted this if this is what they advertised it as. Unfortunately they claimed it was the future of racing and groundbreaking. None of these claims are true. Think I can't wait for PlayStation to finally come out with an amazing racing game. They need to get on it.

Will definitely be interested in "The Crew"... will review that when I get the chance to play it in on release day. Sounds like an arcader which offers a lot more than this!

GRAPHICS 9 / 10
GAMEPLAY 3/10
ONLINE 3/10 (if you can get on)
PHYSICS 3/10
TRACKS 3/10
OVERALL 4/10