• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 23:02
CEST 05:02
KST 12: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
TL.net Map Contest #22 - Voting & Ladder Map Selection2Code S Season 2 (2026) - RO8 Preview5[ASL21] Finals Preview: Two Legacies21Code S Season 2 (2026) - RO12 Preview2herO wins GSL Code S Season 1 (2026)7
Community News
StarCraft II 5.0.16 PTR Patch Notes may 26th122Weekly Cups (May 18-24): MaxPax wins doubles0Crank Gathers Season 4: BW vs SC2 Team League5Weekly Cups (May 11-17): Classic wins double1Code S Season 1 (2026) - RO8 Results2
StarCraft 2
General
The Death of Cheese: From a Professional Cheeser StarCraft II 5.0.16 PTR Patch Notes may 26th TL.net Map Contest #22 - Voting & Ladder Map Selection Code S Season 2 (2026) - RO8 Preview TL Poll: How do you feel about the 5.0.16 PTR balance changes?
Tourneys
Maestros of The Game 2 announcement and schedule ! RSL Revival: Season 5 - Qualifiers and Main Event Crank Gathers Season 4: BW vs SC2 Team League GSL Code S Season 2 (2026) Sparkling Tuna Cup - Weekly Open Tournament
Strategy
[G] Having the right mentality to improve
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players
External Content
The PondCast: SC2 News & Results Mutation # 528 Infection Detected Welcome to the External Content forum Mutation # 527 Hell Train
Brood War
General
FlaShFTW vs A.Alm Grudge Match Event Data needed BGH Auto Balance -> http://bghmmr.eu/ Quality of life changes in BW that you will like ? Soma's ASL Finals Review
Tourneys
[ASL21] Grand Finals [Megathread] Daily Proleagues Escore Tournament StarCraft Season 2 [BSL22] WB Final & LB Semis - Saturday 21:00 CEST
Strategy
Any training maps people recommend? Muta micro map competition [G] Hydra ZvZ: An Introduction Fighting Spirit mining rates
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Warcraft III: The Frozen Throne ZeroSpace Megathread Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
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
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread Dating: How's your luck? Russo-Ukrainian War Thread Trading/Investing Thread Things Aren’t Peaceful in Palestine
Fan Clubs
The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books
Sports
McBoner: A hockey love story 2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Facing Challenges in Mobile App Development
TL Community
The Automated Ban List
Blogs
Esportsmanship: How to NOT B…
TrAiDoS
Why RTS gamers make better f…
gosubay
ramps on octagon
StaticNine
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1957 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
Spain18300 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
Poland17756 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
Spain18300 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
Spain18300 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
Replay Cast
00:00
Enki Epic Series #9
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
WinterStarcraft499
PiGStarcraft499
ProTech394
RuFF_SC2 117
StarCraft: Brood War
GuemChi 5318
Rain 3261
Artosis 473
Snow 123
Bale 70
Noble 39
NaDa 32
Nal_rA 28
Dota 2
monkeys_forever422
LuMiX0
League of Legends
JimRising 751
Counter-Strike
Fnx 1525
shahzam603
taco 481
Super Smash Bros
hungrybox757
Mew2King76
Other Games
C9.Mang0519
Day[9].tv506
Maynarde167
minikerr3
Organizations
Other Games
gamesdonequick997
BasetradeTV230
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 16 non-featured ]
StarCraft 2
• Berry_CruncH112
• Hupsaiya 81
• practicex 12
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Lourlo683
• Stunt553
Other Games
• Day9tv506
Upcoming Events
Sparkling Tuna Cup
6h 58m
WardiTV Spring Champion…
7h 58m
Maestros of the Game
12h 28m
The PondCast
1d 6h
Kung Fu Cup
1d 7h
uThermal 2v2 Circuit
1d 11h
Maestros of the Game
1d 12h
Replay Cast
1d 20h
Replay Cast
2 days
WardiTV Spring Champion…
2 days
[ Show More ]
Maestros of the Game
2 days
Replay Cast
3 days
uThermal 2v2 Circuit
3 days
Maestros of the Game
3 days
Replay Cast
4 days
Solar vs Classic
uThermal 2v2 Circuit
4 days
GSL
5 days
herO vs Rogue
Maru vs Cure
uThermal 2v2 Circuit
5 days
BSL
5 days
Replay Cast
6 days
Monday Night Weeklies
6 days
Liquipedia Results

Completed

KK 2v2 League Season 1
RSL Revival: Season 5
Heroes Pulsing #1

Ongoing

BSL Season 22
IPSL Spring 2026
KCM Race Survival 2026 Season 2
Acropolis #4
CSCL: Masked Kings S4
YSL S3
SCTL 2026 Spring
WardiTV Spring 2026
Maestros of the Game 2
2026 GSL S2
Murky Cup 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026

Upcoming

BSL 22 Non-Korean Championship
CSLAN 4
Blizzard Classic Cup 2026
Kung Fu Cup 2026 Grand Finals
CranK Gathers Season 4: BW vs SC2 Team League
HSC XXIX
uThermal 2v2 2026 Main Event
Heroes Pulsing #3
Heroes Pulsing #2
Esports World Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 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.