Page 1 of 3 [ 33 posts ]  Go to page 1, 2, 3  Next

dcj123
Veteran
Veteran

User avatar

Joined: 2 Sep 2009
Gender: Male
Posts: 10,796

06 Nov 2015, 6:13 pm

Hello,

I thought after being inspired by this thread I would make a official programming thread where we can post code, ask questions and talk about how horrible at coding we are. Anyway, here is some of my code and pics of the output, please don't attack me too hard, I know my logic is screwed up in my java calculator and that I am not a good coder. However, I thought I'd share some of my horrible code and maybe learn something.

Keep it to corrective criticism please, I know I am that bad, so you don't have to tell me. Anyway kicking this list off,

Java

jclac

Source Code
jcalc.java
jcalcframe.java

Screenshot
Image

Temperature Conversion

Source Code
gui_temperatures.java
TemperaturesFrame.java

Screenshot
Image

I have some C programs I'll post later, I seem to have misplaced the Raspberry Pi computer that has that code on it.



Earthling
Veteran
Veteran

User avatar

Joined: 23 Aug 2015
Posts: 3,450

06 Nov 2015, 8:13 pm

I'm happy to see you do
this

Code:
blah()
{
     blah blah
}

instead of this
Code:
blah() {
     blah blah
}

:thumleft:
Much easier too read IMO.



Earthling
Veteran
Veteran

User avatar

Joined: 23 Aug 2015
Posts: 3,450

06 Nov 2015, 8:42 pm

Image
Hmm according to formulas... Let's convert 10 Celsius to Fahrenheit.
10 * 5/9 + 32 = 37.5555555 --> 37 Fahrenheit.
OK, now back.
(37 - 32) * 5/7 = 3.5fdsfdsa --> 3 Celsius.

???



dcj123
Veteran
Veteran

User avatar

Joined: 2 Sep 2009
Gender: Male
Posts: 10,796

07 Nov 2015, 4:16 am

Earthling wrote:
Hmm according to formulas... Let's convert 10 Celsius to Fahrenheit.
10 * 5/9 + 32 = 37.5555555 --> 37 Fahrenheit.
OK, now back.
(37 - 32) * 5/7 = 3.5fdsfdsa --> 3 Celsius.

???


Actually 10 Celsius is 50 Fahrenheit, hang on, let me test the code. I think the code is ok. Something is not adding up on the formula listed which is just a string, the formula used in the code has nothing to do with formula displayed.

Oddly enough, Google shows that formula, somethings not right. One mistake you made is its 5/9 not 5/7 but that doesn't change the fact its not working 8O



guitarman2010
Veteran
Veteran

User avatar

Joined: 12 May 2012
Gender: Male
Posts: 578
Location: Erie, PA

11 Nov 2015, 11:21 pm

Here are some of my crude creations of Python scripts specifically designed to run on the Android OS but they only seem to work on OS versions < 5.x. I used the SL4A app (Scripting Layer 4 Android) to run these and their based on Python 2.6.2

This is a script that will quickly tell you the approximate temperature of the device's battery. I have found it does not work on devices with an a13 or a23 CPU, why that is I have no idea. It was tested on 2 different TI CPUs.

Image

Android_Battery_Temp




This is another simple Python script that allows the user to select an LCD brightness lower than what the system will allow using the basic brightness adjustment. I got the idea for this one because I was tired of using apps that required a process to run in the background to dim the screen. This one was created for Android 4.4 (KitKat) but I do have others for JellyBean and Gingerbread, no ICS version because it's been so long since I used that.
Image

Android (KitKat) LCD Brightness Dimmer




Here is a very, VERY simple clock display program which utilizes XML for the layout. It was designed with a 1024x600 display in mind but can easily be formatted for different resolutions by editing a few parameters in the XML. This was unfinished, apparently I wanted to implement an alarm feature but never got to it. I admit this is a HORRIBLE clock program but it somewhat mimics a bedside digital clock and that was my intention on making it. (Notice in the second screenshot it is 1 minute off from the actual device time)
Image

Image

Android "Digital" Clock Display




Accelerometer level: Here is a very poorly coded rendition of a program that reads raw data from the accelerometer and ultimately displays some symbols which are supposed to represent the "bubble" in a leveling tool. This script does use XML for the layout. The "bubble" does get jittery when close to level but I'm no expert.
Image

Accelerometer Level


_________________
When u hit the walls of sanity, u have no-where to go....


Butterfly88
Veteran
Veteran

User avatar

Joined: 22 Jul 2015
Gender: Female
Posts: 20,013
Location: United States

12 Nov 2015, 6:20 am

Good thread! I know HTML and want to learn CSS next.



UnturnedStone
Deinonychus
Deinonychus

User avatar

Joined: 21 Apr 2015
Age: 39
Posts: 325
Location: Australia

12 Nov 2015, 8:09 pm

Image



RetroGamer87
Veteran
Veteran

User avatar

Joined: 30 Jul 2013
Age: 36
Gender: Male
Posts: 10,970
Location: Adelaide, Australia

13 Nov 2015, 4:07 am

Butterfly88 wrote:
Good thread! I know HTML and want to learn CSS next.
They taught you HTML but hot CSS? Strange. When I did it they had both at once, with emphasis on CSS. I think they taught it that way on purpose to prevent us from trying to do anything using HTML. I can understand why. Better to learn to do it the right way in the first place rather than unlearn what we have learned later.


_________________
The days are long, but the years are short


ZD
Veteran
Veteran

User avatar

Joined: 30 Oct 2015
Gender: Male
Posts: 589
Location: Manchester, England

18 Nov 2015, 8:57 am

Butterfly88 wrote:
Good thread! I know HTML and want to learn CSS next.


Have a go on code academy.


_________________
( If I ignore a reply it's not intentional I get distracted, send me a PM to prompt me :) )


Earthling
Veteran
Veteran

User avatar

Joined: 23 Aug 2015
Posts: 3,450

18 Nov 2015, 10:10 am

The other day I tried making (more like thoughtlessly hacking away) a C++ program that makes text rainbow-colored.
I thought I did this for 20 minutes, but in reality it was more like 2 hours.

Dropped it, but the idea was basically to have two arrays, one for the blank text, one for the colorized text.
Then check uncolored array length and apply rgb hex values according to character position in the string to achieve the rainbow effect in color array.
Honestly, the only problem with it was that I couldn't get the int hex value into the color string...



Earthling
Veteran
Veteran

User avatar

Joined: 23 Aug 2015
Posts: 3,450

18 Nov 2015, 5:59 pm

The other day I tried making (more like thoughtlessly hacking away) a C++ program that makes text rainbow-colored. I thought I did this for 20 minutes, but in reality it was more like 2 hours.

It's alright I guess.



Earthling
Veteran
Veteran

User avatar

Joined: 23 Aug 2015
Posts: 3,450

18 Nov 2015, 6:45 pm

The other day I tried making (more like thoughtlessly hacking away) a C++ program that makes text rainbow-colored. I thought I did this for 20 minutes, but in reality it was more like 2 hours.

That's more like it!



RetroGamer87
Veteran
Veteran

User avatar

Joined: 30 Jul 2013
Age: 36
Gender: Male
Posts: 10,970
Location: Adelaide, Australia

19 Nov 2015, 1:37 am

Very nice! Did you intentionally get it to synchronize between lines?


_________________
The days are long, but the years are short


JamesKavanagh
Hummingbird
Hummingbird

User avatar

Joined: 15 Dec 2011
Age: 30
Gender: Male
Posts: 19
Location: London

12 Dec 2015, 12:05 pm

Cool thread I will be following this for sure as I am currently learning programming though I just started out I have used a little of Ruby,Swift and java but still very much in the starting/practice phase of learning.

Also cool rainbow text that is pretty awesome especially how it changed between lines not sure if that was deliberate but still cool you should make a few variations of it with a few colors each as it is defiantly not something you see everyday also how did u get it to work in the chat? was it just a custom hex code or something ?



Earthling
Veteran
Veteran

User avatar

Joined: 23 Aug 2015
Posts: 3,450

12 Dec 2015, 12:32 pm

Thanks guys. :)

I accidentally deleted the source code, otherwise I could have shown it to you. :(
But the answer to your question is no, that it looks like this is merely conincidence.

JamesKavanagh wrote:
also how did u get it to work in the chat? was it just a custom hex code or something ?

I'm not sure what you mean by that.



JamesKavanagh
Hummingbird
Hummingbird

User avatar

Joined: 15 Dec 2011
Age: 30
Gender: Male
Posts: 19
Location: London

12 Dec 2015, 12:37 pm

Sorry if I was a bit confusing I just meant how did u get the text code to activate inside the forum since I am not that used to using wrong planet so am unsure if there is modifiable options for people who can code custom text ect.?


Confusing myself a little trying to explain but hopefully you get the gist of what I mean