• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:45
CEST 16:45
KST 23:45
  • 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
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Hiatus From ASL50Weekly Cups (June 23-29): Reynor in world title form?12FEL Cracov 2025 (July 27) - $8000 live event16Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
The SCII GOAT: A statistical Evaluation The GOAT ranking of GOAT rankings How does the number of casters affect your enjoyment of esports? Statistics for vetoed/disliked maps Esports World Cup 2025 - Final Player Roster
Tourneys
RSL: Revival, a new crowdfunded tournament series [GSL 2025] Code S: Season 2 - Semi Finals & Finals $5,100+ SEL Season 2 Championship (SC: Evo) FEL Cracov 2025 (July 27) - $8000 live event HomeStory Cup 27 (June 27-29)
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
Player “Jedi” cheat on CSL BGH Auto Balance -> http://bghmmr.eu/ Unit and Spell Similarities Help: rep cant save Flash Announces Hiatus From ASL
Tourneys
[BSL20] Grand Finals - Sunday 20:00 CET [Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Path of Exile What do you want from future RTS games? Beyond All Reason
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
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Trading/Investing Thread The Games Industry And ATVI
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2025 Football Thread NBA General Discussion Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 753 users

The Big Programming Thread - Page 762

Forum Index > General Forum
Post a Reply
Prev 1 760 761 762 763 764 1031 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
Spain17969 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
Poland17243 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
Spain17969 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
Spain17969 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 States14827 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 1031 Next
Please log in or register to reply.
Live Events Refresh
OSC
13:00
King of the Hill #216
davetesta80
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Lowko584
Hui .252
Vindicta 28
StarCraft: Brood War
Britney 57495
Calm 6793
Rain 3544
Shuttle 1426
Horang2 1401
EffOrt 1305
Hyuk 847
Larva 600
Light 294
BeSt 266
[ Show more ]
hero 201
Mini 166
Leta 164
ToSsGirL 113
Mind 87
Mong 75
Pusan 73
Snow 71
Hyun 62
Rush 49
Shinee 47
Barracks 45
JYJ39
Movie 26
soO 24
PianO 18
HiyA 13
Nal_rA 12
Backho 11
Shine 9
yabsab 8
IntoTheRainbow 8
SilentControl 7
zelot 3
Dota 2
Gorgc10538
qojqva2694
League of Legends
singsing2653
Other Games
Grubby2727
B2W.Neo1534
hiko948
DeMusliM571
Fuzer 292
XaKoH 261
ArmadaUGS126
QueenE25
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• IndyKCrew
• sooper7s
• AfreecaTV YouTube
• Migwel
• intothetv
• LaughNgamezSOOP
• Kozan
StarCraft: Brood War
• Michael_bg 9
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 2657
• WagamamaTV410
League of Legends
• Nemesis6783
• Jankos1184
• TFBlade818
Upcoming Events
WardiTV European League
1h 15m
Scarlett vs Percival
Jumy vs ArT
YoungYakov vs Shameless
uThermal vs Fjant
Nicoract vs goblin
Harstem vs Gerald
FEL
1h 15m
Big Brain Bouts
1h 15m
Korean StarCraft League
12h 15m
CranKy Ducklings
19h 15m
RSL Revival
19h 15m
FEL
1d 1h
RSL Revival
1d 19h
FEL
1d 21h
BSL: ProLeague
2 days
Dewalt vs Bonyth
[ Show More ]
Replay Cast
3 days
Sparkling Tuna Cup
3 days
The PondCast
4 days
Replay Cast
5 days
RSL Revival
5 days
Replay Cast
6 days
RSL Revival
6 days
Liquipedia Results

Completed

Proleague 2025-06-28
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
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 © 2025 TLnet. All Rights Reserved.