Desktop Programming

Desktop programming related articles not related to .NET (Java, Python, Ruby etc)

Train / Bus Reservation Example in Java

ALLLLLL ABOARD! Buy your tickets right here for the DIC train of love. In this episode we talk about a problem that pops up once in awhile on the boards, a seat reservation system. People have their preferences and the DIC train is no different. Some people like the windows, some people like the aisle seats and some even like to hang out there in the caboose (Yeah you know ...

Let the Carnage Begin! Josephus Solution in C++

It was a dark stormy night, the staff of DIC had been running all night up this steep mountain trying to avoid the hordes of newbies asking for solutions. "Run for the cave!" yelled supersloth. So the crew ran into the cave hoping to elude the beasts that will not let a programming master sleep. Shortly after the 10 staffers made it safely inside... "BOOM POW CRASH!" the cave entrance ...

Building Shapes With Loops

From time to time it has been asked how to build standard 2D shapes with simple loops. It could be a rectangle of some sort or a right / equilateral triangle. Maybe even a triangle that is facing the left rather than facing the right. Even the diamond pattern is a good one asked by many instructors around. But why on Earth would instructors ask you to build these types ...

Generating Non-Repeating Random Values in C++

I have seen this question pop up on the board from time to time about generating random number values, in a given range, but not repeating any of the values. It is simple enough to create your standard number generator, and even simple to test the value it generates against previously selected values, but that method has always been a "brute force" type of approach and can be a nightmare ...

Euclidean, Bezout, and Coprime Oh My!

Occasionally a programmer loves to play with numbers. Some like to stick gum in their sister's hair, but that is besides the point. At the heart of some programming is the heart of mathematics and especially number theory. One of the great theoretical algorithms out there is the Extended Euclidean algorithm which is used to find the Greatest Common Divisor (GCD). The GCD is a number which divides both of ...

BozoSort Definitive (C++, C#, VB.NET, Java, PHP)

WARNING: PLEASE USE WITH EXTREME CAUTION! CONTENTS MAY BE FUNNY BUT NOT FOR PRODUCTION USE. Programmer Discretion is Advised! Hey you bozos out there, now there is a sort even for you! For those who don't know, a Bozo Sort is a joke sorting algorithm that actually sorts but at horrible timing and is very inefficient. It is good to see it at work from a theoretical stand point but it ...