Jump to content

People learn differently, but the best you could do (normally) is to visit Codeacademy or something like that to get you going, or some tutorials on Youtube

 

I can show you a little dice game I made for a Math project at school, it does contain most of the basics so if you understands that you have a start :)

Main game class: http://pastebin.com/5LyU3NQf

Run game class: http://pastebin.com/z2ZL6dxc
Example of a player: http://pastebin.com/wBLN643q

 

Enjoy

Ryzen 7 5800X     Corsair H115i Platinum     ASUS ROG Crosshair VIII Hero (Wi-Fi)     G.Skill Trident Z 3600CL16 (@3800MHzCL16 and other tweaked timings)     

MSI RTX 3080 Gaming X Trio    Corsair HX850     WD Black SN850 1TB     Samsung 970 EVO Plus 1TB     Samsung 840 EVO 500GB     Acer XB271HU 27" 1440p 165hz G-Sync     ASUS ProArt PA278QV     LG C8 55"     Phanteks Enthoo Evolv X Glass     Logitech G915      Logitech MX Vertical      Steelseries Arctis 7 Wireless 2019      Windows 10 Pro x64

Link to comment
https://linustechtips.com/topic/155994-java-basic-programs/#findComment-2092045
Share on other sites

Link to post
Share on other sites

import java.awt.*;import javax.swing.*; public static void main (String args[]){ gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); gui.setVisible(true); gui.pack(); gui.setTitle("Made in Java");}

As per requested, some Java code. This code creates a actual window in Java to display images[sprites] and other features.

Link to comment
https://linustechtips.com/topic/155994-java-basic-programs/#findComment-2093257
Share on other sites

Link to post
Share on other sites

As per requested, some Java code.

also remember that in other people's programs there are other people's mistakes

and you don't want to learn other people's mistakes

that's another example of what i meant: he forgot to copypaste a crucial part of the code (source)

 

just read a tutorial and experiment java yourself

Link to comment
https://linustechtips.com/topic/155994-java-basic-programs/#findComment-2093368
Share on other sites

Link to post
Share on other sites

I can show you a little dice game I made for a Math project at school, it does contain most of the basics so if you understands that you have a start :)

Main game class: http://pastebin.com/5LyU3NQf

Run game class: http://pastebin.com/z2ZL6dxc

Example of a player: http://pastebin.com/wBLN643q

this ...

also remember that in other people's programs there are other people's mistakes

and you don't want to learn other people's mistakes

Mini-Desktop: NCASE M1 Build Log
Mini-Server: M350 Build Log

Link to comment
https://linustechtips.com/topic/155994-java-basic-programs/#findComment-2094547
Share on other sites

Link to post
Share on other sites

It's simple, just like he wanted it. What did you expect, a game?

no, just a simple java program ...

It doesn't work? I need to review my Java coding...

I think you should start here ...

http://www.learnjavaonline.org/en/Hello%2C_World!

Mini-Desktop: NCASE M1 Build Log
Mini-Server: M350 Build Log

Link to comment
https://linustechtips.com/topic/155994-java-basic-programs/#findComment-2094562
Share on other sites

Link to post
Share on other sites

this ...

What problems? D:

Seemed to work fine for me

Ryzen 7 5800X     Corsair H115i Platinum     ASUS ROG Crosshair VIII Hero (Wi-Fi)     G.Skill Trident Z 3600CL16 (@3800MHzCL16 and other tweaked timings)     

MSI RTX 3080 Gaming X Trio    Corsair HX850     WD Black SN850 1TB     Samsung 970 EVO Plus 1TB     Samsung 840 EVO 500GB     Acer XB271HU 27" 1440p 165hz G-Sync     ASUS ProArt PA278QV     LG C8 55"     Phanteks Enthoo Evolv X Glass     Logitech G915      Logitech MX Vertical      Steelseries Arctis 7 Wireless 2019      Windows 10 Pro x64

Link to comment
https://linustechtips.com/topic/155994-java-basic-programs/#findComment-2094876
Share on other sites

Link to post
Share on other sites

What problems? D:

Seemed to work fine for me

what i meant and probably @MrSuperb as well with that comment is that your code isn't a great 'learning example' either: the fact that a code compiles and even works doesn't mean that it's a good code

the 'good programming' is also made of software design, and that's what a newbie should learn along with the syntax of the language

your code does not make a correct use of java, so it's not something that should be 'studied'

it's a good start for you, who are practising, not for him, who has to learn

Link to comment
https://linustechtips.com/topic/155994-java-basic-programs/#findComment-2095250
Share on other sites

Link to post
Share on other sites

Ookey, I have had 3 courses now at the University which involved Java only or quite alot, I guess there is basic stuff they don't care teaching us d:

Ryzen 7 5800X     Corsair H115i Platinum     ASUS ROG Crosshair VIII Hero (Wi-Fi)     G.Skill Trident Z 3600CL16 (@3800MHzCL16 and other tweaked timings)     

MSI RTX 3080 Gaming X Trio    Corsair HX850     WD Black SN850 1TB     Samsung 970 EVO Plus 1TB     Samsung 840 EVO 500GB     Acer XB271HU 27" 1440p 165hz G-Sync     ASUS ProArt PA278QV     LG C8 55"     Phanteks Enthoo Evolv X Glass     Logitech G915      Logitech MX Vertical      Steelseries Arctis 7 Wireless 2019      Windows 10 Pro x64

Link to comment
https://linustechtips.com/topic/155994-java-basic-programs/#findComment-2095268
Share on other sites

Link to post
Share on other sites

Ookey, I have had 3 courses now at the University which involved Java only or quite alot, I guess there is basic stuff they don't care teaching us d:

class TestPlayer and TestPlayer2? presumibly very similar? with no inheritance? they probably tought you about this

edit: also, saying that your example covers most of the basics is a bit ambitious

Link to comment
https://linustechtips.com/topic/155994-java-basic-programs/#findComment-2095354
Share on other sites

Link to post
Share on other sites

there is very little similar in those classes, I thought of having inheritance but it just seemed unnecessary

 

But when I look over it now, a few things was added a month after initial creation, so now it could have some actually purpose

Ryzen 7 5800X     Corsair H115i Platinum     ASUS ROG Crosshair VIII Hero (Wi-Fi)     G.Skill Trident Z 3600CL16 (@3800MHzCL16 and other tweaked timings)     

MSI RTX 3080 Gaming X Trio    Corsair HX850     WD Black SN850 1TB     Samsung 970 EVO Plus 1TB     Samsung 840 EVO 500GB     Acer XB271HU 27" 1440p 165hz G-Sync     ASUS ProArt PA278QV     LG C8 55"     Phanteks Enthoo Evolv X Glass     Logitech G915      Logitech MX Vertical      Steelseries Arctis 7 Wireless 2019      Windows 10 Pro x64

Link to comment
https://linustechtips.com/topic/155994-java-basic-programs/#findComment-2095373
Share on other sites

Link to post
Share on other sites

if(checkForNewPlayer()){                        bank.put(playerName,0);                }//xxxxxxpublic boolean checkForNewPlayer(){                if(bank.containsKey(playerName)){                        return false;                }                else{                        return true;                }        }

just one example ...

you are jumping around in your code without any structure.

you are ignoring the most basic guidelines how to use OOP

Mini-Desktop: NCASE M1 Build Log
Mini-Server: M350 Build Log

Link to comment
https://linustechtips.com/topic/155994-java-basic-programs/#findComment-2096983
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×