• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 11:34
CET 16:34
KST 00:34
  • 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
ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info8
Community News
2026 KongFu Cup Announcement3BGE Stara Zagora 2026 cancelled12Blizzard Classic Cup - Tastosis announced as captains15Weekly Cups (March 2-8): ByuN overcomes PvT block4GSL CK - New online series19
StarCraft 2
General
GSL CK - New online series BGE Stara Zagora 2026 cancelled Blizzard Classic Cup - Tastosis announced as captains BGE Stara Zagora 2026 announced ByuL: The Forgotten Master of ZvT
Tourneys
RSL Season 4 announced for March-April PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar) Sparkling Tuna Cup - Weekly Open Tournament 2026 KongFu Cup Announcement [GSL CK] Team Maru vs. Team herO
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026] Map Editor closed ?
External Content
The PondCast: SC2 News & Results Mutation # 516 Specter of Death Mutation # 515 Together Forever Mutation # 514 Ulnar New Year
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ BSL 22 Map Contest — Submissions OPEN to March 10 ASL21 General Discussion Are you ready for ASL 21? Hype VIDEO Gypsy to Korea
Tourneys
[Megathread] Daily Proleagues [BSL22] Open Qualifiers & Ladder Tours IPSL Spring 2026 is here! ASL Season 21 Qualifiers March 7-8
Strategy
Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Fighting Spirit mining rates Zealot bombing is no longer popular?
Other Games
General Games
Stormgate/Frost Giant Megathread Path of Exile Nintendo Switch Thread PC Games Sales Thread No Man's Sky (PS4 and PC)
Dota 2
Official 'what is Dota anymore' discussion The Story of Wings Gaming
League of Legends
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
Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Mexico's Drug War Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine NASA and the Private Sector
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! [Req][Books] Good Fantasy/SciFi books
Sports
Formula 1 Discussion 2024 - 2026 Football Thread General nutrition recommendations Cricket [SPORT] TL MMA Pick'em Pool 2013
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
Funny Nicknames
LUCKY_NOOB
Money Laundering In Video Ga…
TrAiDoS
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 3729 users

The Big Programming Thread - Page 762

Forum Index > General Forum
Post a Reply
Prev 1 760 761 762 763 764 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.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2016-09-11 08:03:48
September 11 2016 07:56 GMT
#15221
On September 11 2016 15:19 teamamerica wrote:
Show nested quote +
On September 11 2016 13:21 Blisse wrote:
Also you don't have to make getters and setters unless you need to control access. Just make the members public.


The downside is in Java is that if you wanna change it to a method you have to change every callsite. You can argue that in the case you're refactoring a public property into a method that's not a big deal, but other languages let $object.property be either a direct instance variable lookup or a method call.


To be honest while I've heard that argument I don't really feel like this is an issue, besides ease of IDE refactoring, it's just straightforward manual work. If it's an area you already believe will change often you would have already added it as a g/setter. And if it wasn't predicted to be used like this it often requires more thought into what the actual intended usage is. I never felt this to be an annoyance irl.

The only big issue with this is when you're flipflopping between having the g/setters and not having them, which if you're planning well, just means requirements are changing a lot, and should be normal.


On September 11 2016 16:31 spinesheath wrote:
Show nested quote +
On September 11 2016 12:09 Hhanh00 wrote:
In case you are stuck with Java, you may want to take a look at Project Lombok that uses AOP to inject the boiler plate.

The java code becomes

@Data
public class Animal {
private String type;
private int age;
private String size;
}


and ends up being the same bytecode.

I've looked into AOP but never actually used it. You probably have some actual experience with it. I've always wondered how it affects debugging - you obviously can't step through single lines of code if you never write them. How's that working out for you?


I believe that the annotations are used to compile the annotated class into some generated code before being fed to the actual Java compiler, so debugging should work as normal? I feel like I've done that before...
There is no one like you in the universe.
Acrofales
Profile Joined August 2010
Spain18234 Posts
Last Edited: 2016-09-11 09:16:15
September 11 2016 09:13 GMT
#15222
On September 11 2016 06:55 travis wrote:
Sensing I needed to review and make sure I understand java basics I wrote a pointless program. I wanted to check that I knew how to write things like equals, toString, getters/setters, constructors, and use inheritance correctly.

If anyone has free time could they look at my code and make sure I am not doing anything naughty?
Also I have 3 questions about the code (one in particular is important)


animal class
+ Show Spoiler +

package life;

public class animal {

private String type;
private int age;
private String size;

public animal(){
this.type = "unknown";
this.age = 0;
this.size = "unknown";
}

public animal(int a, String t, String s){
this.age = a;
this.type = t;
this.size = s;
}

public animal(animal oldAnimal){
this.age = oldAnimal.age;
this.type = oldAnimal.type;
this.size = oldAnimal.size;
}




public String toString(){
return ("This is a " + this.type + ", it is " + this.age + " years old, and it is " + this.size);
}


public boolean equals(Object other){
if(this == other){
return true;
}
if(!(other instanceof animal)){
return false;
}

animal a = (animal) other;
return this.toString() == a.toString();
}


public void move(){
System.out.println(this.type + " moved");
}

public void eat(String f){
System.out.println(this.type + " ate " + f);
}











public void setType(String t){
this.type = t;
}

public void setAge(int a){
this.age = a;
}

public void setSize(String s){
this.size = s;
}

public String getType(){
return this.type;
}

public int getAge(){
return this.age;
}

public String getSize(){
return this.size;
}


}




Human Class
+ Show Spoiler +

package life;

public class human extends animal {

private String name;

public human(){
super();
this.name = "unnamed";
}

public human(String n, String t, String s, int a){
super(a, t, s);
this.name = n;
}

public human(human oldHuman){
super(oldHuman);
this.name = oldHuman.name;
}

public String toString(){
return (super.toString() + " and it's name is " + this.name);
}

public boolean equals(Object other){
if(this == other){
return true;
}
if(!(other instanceof human)){
return false;
}

human h = (human) other;

return this.toString() == h.toString();
}






public void complain(String c){
System.out.println(this.name + " complains about " + c);
}

public void setName(String n){
this.name = n;
}

public String getName(){
return this.name;
}

}



"engine"
+ Show Spoiler +

package life;

import java.util.ArrayList;
import java.util.Iterator;

public class life {

public static void main(String[] args) {

ArrayList<human> humanList = new ArrayList<human>();

humanList.add(new human());
humanList.add(new human("Tim", "mammal", "medium", 25));
humanList.add(new human("Burt", "mammal", "huge", 43));
humanList.add(new human(humanList.get(1)));

Iterator<human> iterate = humanList.iterator();

while(iterate.hasNext()){
human thisHuman = iterate.next();
System.out.println(thisHuman.getName());
}

for(human h : humanList){
System.out.println(h.toString());
}

System.out.println(humanList.get(0).equals(humanList.get(1)));

System.out.println(humanList.get(1).equals(humanList.get(3)));


}

}



my questions
+ Show Spoiler +

1.) my equals method is based on what I was taught in lecture. my question is, what is the point of casting the object type when I am already checking if it is an instance of that object type?

in the specific example in lecture the professor does call an equals method within the equals method - he uses super.equals(other), but even with that example I don't understand why the casting is necessary.


2.) when I call super(oldHuman) in my constructor - what sorcery is this. it seems like magic. is this one of those things that java can "just do" ?



3.) System.out.println(humanList.get(1).equals(humanList.get(3))); is returning false. why? shouldn't this return true?




thank you to any kind souls who help me out



In addition to all the useful advice the others have given you, l personally like took keep the order of my parameters the same. So if in your animal constructor you use (age, type, size), it is best to do so for your human class as well. Also, try to use variable names that make sense. While you can now still remember what a, t and s are, I guarantee you won't recall that when you have to extend or revise your code in a few weeks (or some other poor shmoe has to do that).

Oh, and talking about debugging, do you really need that constructor for humans? Do you ever want humans to be of type "dog" and size "microscopic"?
Manit0u
Profile Blog Joined August 2004
Poland17693 Posts
September 11 2016 10:18 GMT
#15223
On September 11 2016 15:19 teamamerica wrote:
Show nested quote +
On September 11 2016 14:44 Wrath wrote:
On September 11 2016 11:11 Manit0u wrote:
On September 10 2016 22:59 Wrath wrote:
Call me a retard but is it normal to waste full day on setting up eclipse with Symfony and run the code against apache httpd server and still not working?


First of all, if you're developing with Symfony you don't even need Apache. Symfony has its own built-in server for development purposes if you need one.

You can of course still use Apache, Nginx or whatever else you need (for Apache note that Symfony doesn't use .htaccess and you must have proper Require All Granted etc. set in your host settings, you can look those up in the Symfony docs).

Second thing is the fact that you should not use Eclipse for that. NetBeans would be better but still shitty. Just for learning you could be using PhpStorm (with super duper mega excellent symfony plugin) in its 30-day free trial (or endless trial if you're a student). Trust me, it's miles apart from any freeware solution. I can't even look at Eclipse or NetBeans after using jetbrains products...


I'm not a student and I can't guarantee that the workplace will provide me a phpstorm. That is why I'm trying to get a free IDE...


If for some reason work refuses to pay for it I'd really recommend just buying it yourself. Idk if you're not in US but if you are it's pretty cheap; I did that for my first job and I didn't regret it at all.


It was the same for me. I did the 30-day trial to see if it's any good and then simply bought it for myself. The additional benefit is that if I go to work somewhere else I still have my phpstorm since it's mine and not company's. It's a good investment that earns its price back tenfold pretty soon in all the work saved and general quality of life.

And I have no idea how come it's super hard to get a good looking dark theme going on with Eclipse or NetBeans. I simply can't stand working with code on white background (NetBeans takes the cake for dumbest implementation here since you have some potential errors shown as light yellow underline which is pretty much invisible). Displaying all the whitespace characters is also a huge pain in those IDEs.
Time is precious. Waste it wisely.
Hhanh00
Profile Joined May 2016
34 Posts
September 11 2016 11:09 GMT
#15224
On September 11 2016 16:31 spinesheath wrote:
Show nested quote +
On September 11 2016 12:09 Hhanh00 wrote:
In case you are stuck with Java, you may want to take a look at Project Lombok that uses AOP to inject the boiler plate.

The java code becomes

@Data
public class Animal {
private String type;
private int age;
private String size;
}


and ends up being the same bytecode.

I've looked into AOP but never actually used it. You probably have some actual experience with it. I've always wondered how it affects debugging - you obviously can't step through single lines of code if you never write them. How's that working out for you?


When the tool generates bytecode directly, you won't have source code but some of the IDE can decompile it for you automatically. Since it's just boilerplate code, it is best stepped over and treated like library code.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2016-09-11 20:46:23
September 11 2016 17:52 GMT
#15225
-.-
Acrofales
Profile Joined August 2010
Spain18234 Posts
Last Edited: 2016-09-11 18:21:07
September 11 2016 18:20 GMT
#15226
The problem sounds underspecified, but it depends a lot on the size of your arrays. If your match list is small, you can do it that way, and never really have too many permutations to handle. But the number of possible permutations grows exponentially (n! in fact), so it can get intractable pretty quickly.

Another option is to use a sliding window on your target array, and see if it contains all of your search terms. You start with windows of the same size as your search array, and if you don't find any matches, increase by 1 and repeat. Stop when you find a match (which is guaranteed to be (one of) the shortest).

You can start by sliding your window one item at a time, but can speed up the algorithm by skipping windows you know cannot possibly match.
Hhanh00
Profile Joined May 2016
34 Posts
September 11 2016 18:26 GMT
#15227
Can the lists have duplicate values?
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2016-09-11 20:46:35
September 11 2016 19:00 GMT
#15228
-.-
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2016-09-11 19:27:54
September 11 2016 19:23 GMT
#15229
It's interesting that they're asking problems like that for you to solve this early. That's something that I would expect in a programming interview.

If you're comfortable, I believe using a dynamically-sized sliding window is the "optimal" solution, but it probably involves a few new concepts you haven't learned yet. Using a dictionary/map can help.
There is no one like you in the universe.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2016-09-11 21:45:00
September 11 2016 19:48 GMT
#15230
--- Nuked ---
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
September 11 2016 19:59 GMT
#15231
geeze does that really not have flaws because that solution not only sounds efficient but also pretty easy to do


can't really think of any problems with it..
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
September 11 2016 20:28 GMT
#15232
Did you consider the possibility that some of the values to look for are duplicates? Would you have to match as many duplicates in the list?
If you have a good reason to disagree with the above, please tell me. Thank you.
Acrofales
Profile Joined August 2010
Spain18234 Posts
September 11 2016 20:30 GMT
#15233
Nesserev wins. Far more efficient.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2016-09-11 20:47:46
September 11 2016 20:46 GMT
#15234
I am actually going to edit my posts because I carefully read about academic integrity for our CS department and apparently discussing projects on forums at all is a violation. they are so vague about it

which is complete bullshit since that's basically saying you can't go learn about what you are doing

and anyone could do google searches to find algorithms to do exactly this

but w/e, better safe than sorry

next time I will discuss these concepts in a safer way

and yeah I know this is paranoid but my school is very big and I am sure there are some CS students who go to TL
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
September 11 2016 21:28 GMT
#15235
--- Nuked ---
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2016-09-11 21:38:55
September 11 2016 21:37 GMT
#15236
it wouldn't hurt I guess

based on other things I have seen professors say this shouldn't really be a violation, but the rules are so vague that I could get screwed over if they wanted

they literally say that it is an academic integrity violation to:

"Using online forums to ask for help regarding our assignments."

which is the vaguest nonsense ever

it's kind of like saying that I can't use online forums to discuss how to program
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2016-09-11 22:00:06
September 11 2016 21:52 GMT
#15237
Yeah, academic integrity policy is intentionally vague so that it's a lot easier on them when they provide proof. Generally it's fine as long as you're just talking about the solution and not given exact pseudo/code. All reasonable professors I've seen encourage discussion, just not discussion with code being written.

I've consulted TL for a bunch of things too.

Instead of giving the problem description, you should abstract it one step up. I know it's a bit harder to do since you're starting out, but asking, "how do you find the smallest range of numbers in a list that contains a given set of numbers?" gives essentially the same solutions, and as long as no one is writing out a program for you, it should be fine asking for help.

-----

Actually it's kind of annoying/interesting that a lot of programming questions essentially rely on tricks that you need to learn first before you can actually solve them. Using sets and dictionaries IMO don't come intuitively, but instead from me reading advice that they're generally how to best solve a problem, and then I base my thinking with that in mind. I think the extreme example is being asked to find a loop in a linked list. No way you can reason yourself to a solution.
There is no one like you in the universe.
Shaella
Profile Blog Joined January 2013
United States14828 Posts
September 12 2016 03:41 GMT
#15238
Gentlemen i am inspired.

Inspired by the azarkon mute script, I've been trying to create a version for a completely different forum that accomplishes the same task.

Problem being this is a zetaboards forum and everything in it seems to be contained in endless fucking tables.

Any advice? It shouldn't be that hard if I know what i'm looking for i just don't know where to start.
don't tell me to provide a legend for those charts cause we already got shaella in this thread - eieio | Bulba is my waifu
Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
Last Edited: 2016-09-12 04:06:20
September 12 2016 04:05 GMT
#15239
I haven't done much with userscripts before but pretty sure they have easy access to the DOM, so you just need to find how posts are stored in the DOM and then find the element with the username you want to hide, then remove it. IDK if that's enough to go off or you need more specifics though.

E.g.

<tr id="post-8073303">
<td class="c_username">
<a href='http://s9.zetaboards.com/Ultimate3D_community/profile/44616/' class='member'>AZARKON THE GREAT</a><a name='post8073303'></a>
</td>

So you just navigate the DOM for anything with id = post-SOMETHING, then within its children, check class=member, check the text for the usernames you want to hide, and if so use whatever DOM manipulation userscripts have to hide/remove the whole post tr.
Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
September 12 2016 04:25 GMT
#15240
On September 12 2016 06:52 Blisse wrote:
Yeah, academic integrity policy is intentionally vague so that it's a lot easier on them when they provide proof. Generally it's fine as long as you're just talking about the solution and not given exact pseudo/code. All reasonable professors I've seen encourage discussion, just not discussion with code being written.

I've consulted TL for a bunch of things too.

Instead of giving the problem description, you should abstract it one step up. I know it's a bit harder to do since you're starting out, but asking, "how do you find the smallest range of numbers in a list that contains a given set of numbers?" gives essentially the same solutions, and as long as no one is writing out a program for you, it should be fine asking for help.

-----

Actually it's kind of annoying/interesting that a lot of programming questions essentially rely on tricks that you need to learn first before you can actually solve them. Using sets and dictionaries IMO don't come intuitively, but instead from me reading advice that they're generally how to best solve a problem, and then I base my thinking with that in mind. I think the extreme example is being asked to find a loop in a linked list. No way you can reason yourself to a solution.

I mean, I'm not particularly good, but couldn't you just put the pointer values of each node in a dict when visited, and if you come to a node already in the dict, then you've got a loop?
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Prev 1 760 761 762 763 764 1032 Next
Please log in or register to reply.
Live Events Refresh
WardiTV Team League
12:00
Group B
WardiTV1068
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
MindelVK 44
StarCraft: Brood War
Calm 16514
firebathero 7248
Horang2 2172
Jaedong 1964
BeSt 427
Mini 425
EffOrt 410
Stork 307
Rush 242
Soma 220
[ Show more ]
Dewaltoss 157
actioN 121
Last 92
ToSsGirL 72
Mind 66
sorry 51
Backho 48
Barracks 40
IntoTheRainbow 31
Hm[arnc] 31
JulyZerg 30
Aegong 26
GoRush 20
Nal_rA 20
Terrorterran 13
NaDa 12
ivOry 9
SilentControl 9
Dota 2
Gorgc7200
BananaSlamJamma140
capcasts10
Counter-Strike
fl0m2807
byalli1076
kRYSTAL_39
Heroes of the Storm
Khaldor579
Liquid`Hasu376
Other Games
B2W.Neo1490
Liquid`RaSZi1159
DeMusliM266
Mlord199
KnowMe192
Hui .171
Fuzer 158
crisheroes135
Mew2King59
Organizations
Dota 2
PGL Dota 2 - Main Stream22004
Other Games
gamesdonequick889
ComeBackTV 267
StarCraft: Brood War
lovetv 18
Kim Chul Min (afreeca) 13
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 19 non-featured ]
StarCraft 2
• StrangeGG 75
• musti20045 45
• poizon28 35
• iHatsuTV 15
• Adnapsc2 13
• Response 2
• sooper7s
• intothetv
• Kozan
• IndyKCrew
• AfreecaTV YouTube
• LaughNgamezSOOP
• Migwel
StarCraft: Brood War
• blackmanpl 33
• iopq 1
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 1345
Upcoming Events
Patches Events
1h 26m
BSL
4h 26m
GSL
16h 26m
Wardi Open
20h 26m
Monday Night Weeklies
1d 1h
WardiTV Team League
1d 20h
PiGosaur Cup
2 days
Kung Fu Cup
2 days
OSC
3 days
The PondCast
3 days
[ Show More ]
KCM Race Survival
3 days
WardiTV Team League
3 days
Replay Cast
4 days
KCM Race Survival
4 days
WardiTV Team League
4 days
Korean StarCraft League
5 days
uThermal 2v2 Circuit
5 days
BSL
6 days
Liquipedia Results

Completed

Proleague 2026-03-13
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
Jeongseon Sooper Cup
BSL Season 22
RSL Revival: Season 4
Nations Cup 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

CSL Elite League 2026
ASL Season 21
Acropolis #4 - TS6
2026 Changsha Offline CUP
Acropolis #4
IPSL Spring 2026
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
NationLESS Cup
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open 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.