• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 18:02
CEST 00:02
KST 07:02
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL21] Ro8 Preview Pt1: Inheritors6[ASL21] Ro16 Preview Pt2: All Star10Team Liquid Map Contest #22 - The Finalists17[ASL21] Ro16 Preview Pt1: Fresh Flow9[ASL21] Ro24 Preview Pt2: News Flash10
Community News
2026 GSL Season 1 Qualifiers19Maestros of the Game 2 announced92026 GSL Tour plans announced15Weekly Cups (April 6-12): herO doubles, "Villains" prevail1MaNa leaves Team Liquid25
StarCraft 2
General
Team Liquid Map Contest #22 - The Finalists MaNa leaves Team Liquid Maestros of the Game 2 announced 2026 GSL Tour plans announced Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament 2026 GSL Season 1 Qualifiers INu's Battles#14 <BO.9 2Matches> GSL CK: More events planned pending crowdfunding RSL Revival: Season 5 - Qualifiers and Main Event
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
Mutation # 523 Firewall Mutation # 522 Flip My Base The PondCast: SC2 News & Results Mutation # 521 Memorable Boss
Brood War
General
[ASL21] Ro8 Preview Pt1: Inheritors Leta's ASL S21 Ro.16 review FlaSh: This Will Be My Final ASL【ASL S21 Ro.16】 BGH Auto Balance -> http://bghmmr.eu/ ASL21 General Discussion
Tourneys
[ASL21] Ro16 Group D [Megathread] Daily Proleagues Escore Tournament StarCraft Season 2 [ASL21] Ro16 Group C
Strategy
Simple Questions, Simple Answers What's the deal with APM & what's its true value Any training maps people recommend? Fighting Spirit mining rates
Other Games
General Games
Nintendo Switch Thread Dawn of War IV Diablo IV Total Annihilation Server - TAForever Starcraft Tabletop Miniature Game
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread European Politico-economics QA Mega-thread Canadian Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion McBoner: A hockey love story
World Cup 2022
Tech Support
Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Sexual Health Of Gamers
TrAiDoS
lurker extra damage testi…
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1606 users

The Big Programming Thread - Page 408

Forum Index > General Forum
Post a Reply
Prev 1 406 407 408 409 410 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
icystorage
Profile Blog Joined November 2008
Jollibee19350 Posts
Last Edited: 2013-12-12 08:13:33
December 12 2013 08:11 GMT
#8141
if anybody is familiar with angularjs, i have a problem

<tr ng-repeat="row in data.employeeGaps | filter:search">

<td>{{ row.employeeId | employeeFilter : eData.employees}}</td>

the employeeFilter filters the id into the corresponding names


if i type in the search bar, it only 'recognizes' or filters the employeeId and not the name.

how do i solve this?
my initial solution is to rewrap things in the controller and pass it back into the scope but its very messy and im looking for a more elegant solution.

tldr: filtering the filtered data
LiquidDota StaffAre you ready for a Miracle-? We are! The International 2017 Champions!
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
December 12 2013 10:32 GMT
#8142
Thanks for replies. I have another question. When should one prefer an abstract class over an interface? What the thought process is when one needs to make a decision regarding the two?
Roman666
Profile Joined April 2012
Poland1440 Posts
December 12 2013 11:11 GMT
#8143
On December 12 2013 19:32 darkness wrote:
Thanks for replies. I have another question. When should one prefer an abstract class over an interface? What the thought process is when one needs to make a decision regarding the two?

Few things that come into my mind immediately:

- Interface is stateless - i.e. it cannot define any fields, while abstract class can
- Multiple inheritance - you can implement multiple interfaces, while you can only extend one abstract class.
- Forcing implementation - when you define a method in interface, class that implements it, must also implement the method. When extending an abstract class, you don't have to implement everything.
- Shared implementation - say you need to have the same functionality shared across a set of components - in abstract class you can define a behavior that will be shared across all components that extend this class. In interface you would need to define the method for each component separately, and to share a functionality you would essentially need to re use the same code everywhere.
ExChill
Profile Joined September 2011
Germany179 Posts
Last Edited: 2013-12-15 19:25:00
December 15 2013 19:23 GMT
#8144
Hey
I tried to change an image after clicking it with the following code:
<input type="image" src="/images/refresh.png" alt="Refresh" onclick="this.src='/images/reload.gif'">

But when I click the image the following error image apperas:
[image loading]

If I include the GIF on some other point of the website both (the new one that I included and the changed one from the code above) load correctly.

I hope someone has an idea to resolve the problem

Regards, ExChill
https://twitter.com/ExChill_
tofucake
Profile Blog Joined October 2009
Hyrule19208 Posts
December 15 2013 21:22 GMT
#8145
image is not a valid type for input
Liquipediaasante sana squash banana
ExChill
Profile Joined September 2011
Germany179 Posts
December 15 2013 21:37 GMT
#8146
The image is the submit button. It is listed here.
https://twitter.com/ExChill_
Yoshi-
Profile Joined October 2008
Germany10227 Posts
December 15 2013 21:52 GMT
#8147
Just use a normal image tag, should be easier.
tofucake
Profile Blog Joined October 2009
Hyrule19208 Posts
Last Edited: 2013-12-15 23:55:24
December 15 2013 23:52 GMT
#8148
On December 16 2013 06:37 ExChill wrote:
The image is the submit button. It is listed here.

no, it's not
you would have type="submit" in that case. Also, w3schools is vile and you shouldn't use it. http://www.w3fools.com/
Liquipediaasante sana squash banana
Yoshi-
Profile Joined October 2008
Germany10227 Posts
Last Edited: 2013-12-16 00:02:10
December 16 2013 00:01 GMT
#8149
On December 16 2013 08:52 tofucake wrote:
Show nested quote +
On December 16 2013 06:37 ExChill wrote:
The image is the submit button. It is listed here.

no, it's not
you would have type="submit" in that case. Also, w3schools is vile and you shouldn't use it. http://www.w3fools.com/


That is just wrong
An input with type="image" works exactly the same(apart from the fact that it shows an image, and that it sends the coordinates where you clicked) as a submit button...
tofucake
Profile Blog Joined October 2009
Hyrule19208 Posts
Last Edited: 2013-12-16 00:13:17
December 16 2013 00:12 GMT
#8150
cool, learned something new today

but w3schools is still terrible

anyway the problem is probably the absolute path. Try getting rid of the first forward slash
Liquipediaasante sana squash banana
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
Last Edited: 2013-12-16 01:06:18
December 16 2013 01:05 GMT
#8151
On December 12 2013 19:32 darkness wrote:
Thanks for replies. I have another question. When should one prefer an abstract class over an interface? What the thought process is when one needs to make a decision regarding the two?


Well the original intention was to fulfil has/is_a relationships. So for example a triangle is_a shape, a triangle has corners and has color.

So the general concensus is that if a class IS something, then inherit a base class, if it HAS or is ABLE to do something then use an interface.

A Player IS a Unit, that HAS an inventory, and is ABLE to render (Renderable).

This methodology kind of faded out after people realised that vertical hierarchies cause a lot of fragility.

Instead you are better off as seeing objects as units that provide a service and have roles and responsibilities. These objects work together to solve a problem. a.k.a composition.

So basically just use interfaces for collection purposes only (e.g a collection of renderable objects) and delegate functionality to objects to keep your code DRY, rather than reimplementing code.

Implementation inheritance should only happen if you know you don't have code that is changing all the time inside it. In an interview situation a Triangle should inherit from a Shape abstract base class. In reality though you would have a Shape interface and delegate functionality to all different objects, e.g A Renderer, A Polygon Event handler, etc.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
Fairon
Profile Blog Joined January 2011
Russian Federation80 Posts
Last Edited: 2013-12-16 01:10:54
December 16 2013 01:08 GMT
#8152
Hello everyone!

A couple of weeks ago I started my first lesson at codeacademy.org, and at the moment I finished 26% of java courses.
I've just wrote my "Rock Paper Scissors" game, and I decided that it would be cool to run this simple program not only on codeacademy website but also on my PC. I installed eclipse, created new project and realized that "one does not simply" copy/paste your codeacademy code to eclipse and run it. Luckly, I remembered about awesome TL programming thread! So here is the question, I would be very thankful if you guys can help me:

Q: How can I run codeacademy code on my PC? Here it is:


var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
}
var compare = function (choice1,choice2) {
if (choice1 === choice2) {
return "The result is a tie!";
}

if (choice1 === "rock") {
if (choice2 === "scissors") {
return "Rock wins!";
}
else {return "Paper wins!"}
}
if (choice1 === "paper") {
if (choice2 === "rock") {
return "Paper wins!";
}
else {return "scissors wins!"}
}
if (choice1 === "scissors") {
if (choice2 === "paper") {
return "Scissors wins!";
}
else {return "Rock wins!"}
}
compare(userChoice,computerChoice);
};
CalendarWork Hard, Go Pro @artemfairon
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
Last Edited: 2013-12-16 03:17:40
December 16 2013 02:35 GMT
#8153
On December 16 2013 10:08 Fairon wrote:
Hello everyone!

A couple of weeks ago I started my first lesson at codeacademy.org, and at the moment I finished 26% of java courses.
I've just wrote my "Rock Paper Scissors" game, and I decided that it would be cool to run this simple program not only on codeacademy website but also on my PC. I installed eclipse, created new project and realized that "one does not simply" copy/paste your codeacademy code to eclipse and run it. Luckly, I remembered about awesome TL programming thread! So here is the question, I would be very thankful if you guys can help me:

Q: How can I run codeacademy code on my PC? Here it is:


var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
}
var compare = function (choice1,choice2) {
if (choice1 === choice2) {
return "The result is a tie!";
}

if (choice1 === "rock") {
if (choice2 === "scissors") {
return "Rock wins!";
}
else {return "Paper wins!"}
}
if (choice1 === "paper") {
if (choice2 === "rock") {
return "Paper wins!";
}
else {return "scissors wins!"}
}
if (choice1 === "scissors") {
if (choice2 === "paper") {
return "Scissors wins!";
}
else {return "Rock wins!"}
}
compare(userChoice,computerChoice);
};

Did you put it inside a Main String Args[](a.k.a main function)? Have you tried placing it inside a project? What went wrong?

In general, you can just create a New Project, use the interface they give, and then put your code in the Main String Args[] section(within the brackets). Most other beginner questions can probably be answered or shown in tutorials found through Googling.

EDIT: Also, maybe this is a bit of stupidity on my part not recognizing what your code is, but in general your function should have the return type and input types specified. So it would look something like:

public String compare(int userChoice, int computerChoice){

#Code

}

Where your choice(R/P/S) would be integer values of 0 = Rock, 1 = Paper, 2 = Scissors.

EDIT THE SECOND:

I made a version of it for you to see what I mean by the implementation. Originally my version didn't pass values back and instead just printed it in main because it's a simple function, but this shows you how to pass the values:

+ Show Spoiler +
import java.util.Random;
import java.util.Scanner;


public class RPSMain {

/**
* @param args
*/
public static void main(String[] args) {
System.out.println("Welcome to the Rock Paper Scissors game! \n" +
"Enter 0 for Rock, 1 for Paper, 2 for Scissors: ");
//Ask the user for the input.

Scanner scan = new Scanner(System.in);//Create a Scanner to be used for getting the input.
int userChoice = scan.nextInt();//The scanner will take the next integer input and put it in userChoice

Random generator = new Random();
int computerChoice = generator.nextInt(3);//Produce random int from 0 to 2.

System.out.println(compare(userChoice, computerChoice));
scan.close();
}

public static String compare(int userChoice, int computerChoice){
String printString = " ";
if (userChoice == computerChoice){
printString = "It is a tie! You both entered " + userChoice + ".";
}
else if ((userChoice-computerChoice) == 1|| (userChoice-computerChoice) == -2){
printString = "The computer chose "+ computerChoice + ". \nYou WIN!";
}
else {
printString = "The computer chose "+ computerChoice +". \nYou LOSE!";
}

return printString;
}
}
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
December 16 2013 05:16 GMT
#8154
By the way, Fairon, if you can't get my code working lemme know. I'm just studying for exams right now so I have a bit of extra time to answer questions. After you get your code working, you should look into something called an Enumeration to represent the R/P/S choices.

Here is some documentation for it: http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Fairon
Profile Blog Joined January 2011
Russian Federation80 Posts
Last Edited: 2013-12-16 09:36:53
December 16 2013 09:32 GMT
#8155
On December 16 2013 14:16 WarSame wrote:
By the way, Fairon, if you can't get my code working lemme know. I'm just studying for exams right now so I have a bit of extra time to answer questions. After you get your code working, you should look into something called an Enumeration to represent the R/P/S choices.

Here is some documentation for it: http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html


Thanks a lot for your help! I tried to run the code your wrote but unfortunately got this error message:


Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Scanner cannot be resolved to a type
Scanner cannot be resolved to a type
Random cannot be resolved to a type
Random cannot be resolved to a type


When I tried to run my original code I had errors almost in every single line. And yeah, I put it inside of the main function (luckly I've read a short guide how to write and run programs on eclipse). That's why I was a little bit confused and curious if it's even possible to run the codeacademy code outside of a platform.
CalendarWork Hard, Go Pro @artemfairon
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
Last Edited: 2013-12-16 10:06:19
December 16 2013 09:53 GMT
#8156
Farion, your code is not Java code, it's Javascript. Java and Javascript are two completely different things, you can't use Javascript code in a Java project. The names are similar, but there's no relation. Javascript is a form of Ecmascript historically used to script browsers, Java is a full-on programming language.

You don't need eclipse or anything like it to run javascript, it already runs in your browser. Just make a html page yourself and open it in IE, Chrome or Firefox and it will run.
Prillan
Profile Joined August 2011
Sweden350 Posts
December 16 2013 09:53 GMT
#8157
On December 16 2013 10:08 Fairon wrote:
Hello everyone!

A couple of weeks ago I started my first lesson at codeacademy.org, and at the moment I finished 26% of java courses.
I've just wrote my "Rock Paper Scissors" game, and I decided that it would be cool to run this simple program not only on codeacademy website but also on my PC. I installed eclipse, created new project and realized that "one does not simply" copy/paste your codeacademy code to eclipse and run it. Luckly, I remembered about awesome TL programming thread! So here is the question, I would be very thankful if you guys can help me:

Q: How can I run codeacademy code on my PC? Here it is:

+ Show Spoiler +

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
}
var compare = function (choice1,choice2) {
if (choice1 === choice2) {
return "The result is a tie!";
}

if (choice1 === "rock") {
if (choice2 === "scissors") {
return "Rock wins!";
}
else {return "Paper wins!"}
}
if (choice1 === "paper") {
if (choice2 === "rock") {
return "Paper wins!";
}
else {return "scissors wins!"}
}
if (choice1 === "scissors") {
if (choice2 === "paper") {
return "Scissors wins!";
}
else {return "Rock wins!"}
}
compare(userChoice,computerChoice);
};

This is expected since the code you wrote is in JavaScript, not Java. This also means that you've already run the code on your computer when you wrote it.
TheBB's sidekick, aligulac.com | "Reality is frequently inaccurate." - Douglas Adams
Fairon
Profile Blog Joined January 2011
Russian Federation80 Posts
December 16 2013 10:11 GMT
#8158
Oh man, how come I didn't notice such a simple thing... That explains pretty much everything. Thanks guys, now I got it!
CalendarWork Hard, Go Pro @artemfairon
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
December 16 2013 11:42 GMT
#8159
I've noticed some tutorials run their GUIs as a thread, e.g.:


public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {

@Override
public void run() {
FrameSize fS = new FrameSize();
}
});
}


Any difference between running it from main() or from a Thread#run?
bangsholt
Profile Joined June 2011
Denmark138 Posts
December 16 2013 13:43 GMT
#8160
http://stackoverflow.com/questions/12667105/why-should-i-use-a-separate-thread-to-show-a-gui-in-java

I typed "why run gui from separate thread" in Google. You really should google before asking... Then if you still have questions, then you can ask more specific ones which gives better answers.
Prev 1 406 407 408 409 410 1032 Next
Please log in or register to reply.
Live Events Refresh
BSL
19:00
RO16 TieBreaker - Group B
Artosis vs Jimin
cavapoo vs LancerX
ZZZero.O444
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 498
elazer 161
ROOTCatZ 155
ProTech133
StarCraft: Brood War
Calm 2286
ZZZero.O 444
Mini 317
Horang2 281
ggaemo 122
Dewaltoss 101
NaDa 9
Dota 2
monkeys_forever246
League of Legends
Doublelift3187
JimRising 408
Super Smash Bros
C9.Mang01075
Mew2King84
Heroes of the Storm
Khaldor284
Other Games
gofns14183
tarik_tv10203
summit1g9447
Grubby4035
crisheroes233
ToD194
uThermal135
UpATreeSC53
kaitlyn34
Organizations
Other Games
gamesdonequick1204
BasetradeTV375
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 19 non-featured ]
StarCraft 2
• Hupsaiya 42
• davetesta18
• musti20045 16
• Kozan
• AfreecaTV YouTube
• sooper7s
• intothetv
• IndyKCrew
• LaughNgamezSOOP
• Migwel
StarCraft: Brood War
• 3DClanTV 42
• Airneanach23
• RayReign 7
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota21488
Other Games
• imaqtpie1233
• Scarra896
Upcoming Events
CranKy Ducklings
1h 58m
Replay Cast
10h 58m
Afreeca Starleague
11h 58m
Soma vs hero
Wardi Open
12h 58m
Monday Night Weeklies
17h 58m
Replay Cast
1d 1h
Replay Cast
1d 10h
Afreeca Starleague
1d 11h
Leta vs YSC
Replay Cast
3 days
The PondCast
3 days
[ Show More ]
KCM Race Survival
3 days
Replay Cast
4 days
Replay Cast
4 days
Escore
4 days
Replay Cast
5 days
Replay Cast
5 days
IPSL
5 days
Ret vs Art_Of_Turtle
Radley vs TBD
BSL
5 days
Replay Cast
6 days
uThermal 2v2 Circuit
6 days
BSL
6 days
IPSL
6 days
eOnzErG vs TBD
G5 vs Nesh
Liquipedia Results

Completed

Escore Tournament S2: W4
RSL Revival: Season 4
NationLESS Cup

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
StarCraft2 Community Team League 2026 Spring
Nations Cup 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026

Upcoming

Escore Tournament S2: W5
KK 2v2 League Season 1
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
RSL Revival: Season 5
2026 GSL S1
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
BLAST Rivals Spring 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.