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.
On October 22 2013 09:59 icystorage wrote: guys. i want to google something but i dont know the keywords. what i want to do is that i want a checker that checks if my { ends with }.
is it too confusing? i forgot what that is called >.>
nvm. ctrl+f does the trick lol
why not just compile it or you can also use a text editor that does bracket highlighting
Hey, if any of you guys did the Berkeley edX graphics course assignment, could you send me your gluLookAt() function? I got all the other parts working, I just couldn't get the lookAt to display the lamp. Amazingly I still got 1 correct picture submitted. It was kinda frustrating :/
On October 22 2013 07:17 Yoshi- wrote: I think the only appropriate solution to any of these problems, would be to reconsider why you would even run into them, since pretty much all of them are so absurd that they only should occur in terrible design.
Because they are fun and they stretch your brain a little bit? The process and analysis/comparison of different solutions are more important than the solution itself in terms of learning. Although, coming up with the cleverest/fastest solution is where the fun part comes in.
The disappointing part is that a lot of companies use these kinds of problems for interview questions. It makes for a really bad signal. All you learn is whether or not the candidate knows how to twiddle bits (which is useless in almost all areas of software), or is good at figuring out trivia kinds of tricks. You don't learn anything useful about whether or not the candidate can actually code, or can think about realistic system designs. It's basically a waste of time in an interview.
Outside of an interview setting they make fun brain teasers though. For example, how do you compute the max of two integers using no branch/jump/etc (basically no if statements, no ? : business).
On October 22 2013 13:24 Blisse wrote: Hey, if any of you guys did the Berkeley edX graphics course assignment, could you send me your gluLookAt() function? I got all the other parts working, I just couldn't get the lookAt to display the lamp. Amazingly I still got 1 correct picture submitted. It was kinda frustrating :/
Hey, I'm doing that course right now and I just did that assignment ^^ I will pm you the code for that since it's past due already with some comments to explain some things I got wrong the first few times.
On October 22 2013 07:17 Yoshi- wrote: I think the only appropriate solution to any of these problems, would be to reconsider why you would even run into them, since pretty much all of them are so absurd that they only should occur in terrible design.
Because they are fun and they stretch your brain a little bit? The process and analysis/comparison of different solutions are more important than the solution itself in terms of learning. Although, coming up with the cleverest/fastest solution is where the fun part comes in.
The disappointing part is that a lot of companies use these kinds of problems for interview questions. It makes for a really bad signal. All you learn is whether or not the candidate knows how to twiddle bits (which is useless in almost all areas of software), or is good at figuring out trivia kinds of tricks. You don't learn anything useful about whether or not the candidate can actually code, or can think about realistic system designs. It's basically a waste of time in an interview.
Outside of an interview setting they make fun brain teasers though. For example, how do you compute the max of two integers using no branch/jump/etc (basically no if statements, no ? : business).
If the only solution is a bit trick, and/or the interviewer puts huge weight only on coming up with that solution, then it's bad yes. The process is the most important part, the clever solution is a bonus.
Anyone have an integer validation function for c++? I am having trouble with mine in that if i input 123abc it will pass it as an integer. Also mine reads one character at a time so if I put it into a loop it will prompt the user to enter another number x amount of times depending on how many characters were entered. For example, if "abc" was entered, it would display You did not enter a number. Enter a number You did not enter a number Enter a number You did not enter a number Enter a number My function: + Show Spoiler +
bool numValidate (string xString) { int xInt = 0; char xChar; int strLength; bool boolDigit = false;
strLength = xString.length();
for (int i = 0, ii = strLength-1; i < strLength; i++, ii--) { xChar = xString.at(i); boolDigit = isdigit(xChar);
if (boolDigit) { xInt += ((int)(xChar) - (int)('0')) * pow(10.0, (double)(ii)) ; } else { cout << "You did not enter a number" << endl; break; } } return boolDigit; }
Use the code tag on TL: [ code][ /code] without the extra spaces of course. Spoiler tag is not readable.
If you just want to USE a integer validation function, by all means use an existing one like those bangsholt mentioned.
If you want to implement your own function for practice purposes, you'll need to fix a few things. If all you want to do is validation, get rid of the whole number evaluation stuff. If you find a non-digit, you can use break; to exit the loop immediately. Don't call your variables "xTypename". That doesnt say anything. Give them names that describe their use or purpose. If you want to calculate the number, start with int result = 0; and each run through the loop first multiply result by 10, then add the value of the next digit. Gets rid of stupid pow() and double casts. Don't put any console output into the function. Don't use multiple loop variables, unreadable. Rather calculate the second one based on the first one inside the loop, though it's just not necessary here.
On October 21 2013 10:47 darkness wrote: I'm still trying to figure out composition in practice not theory.
So, for example:
private SomeClass sc;
// constructor public Main(SomeClass sc) { this.sc = sc; }
public int getSomeValue() { // get some value from SomeClass return sc.value; }
Is SomeClass considered part of composition?
I know this is a bit old, but it was not answered deeply enough for my taste.
Composition means that the referencing class does not only hold an instance of the referenced class but also is responsible for creating such instance(s).
Your example is an aggregation, where the instance of the referenced class can exist with or without the referencing instance.
Example: A room can only exist within a certain building. Therefore it would be suitable to have buildings being composed of rooms. A chair can exist within a room, but also outside of that room. Therefore it would be suitable to have a room aggregate chair(s).
On October 22 2013 07:46 waxypants wrote: A quick search turned up TCC (tiny c compiler). I downloaded it, it's a couple megs and compiled HelloWorld just fine on Windows! I imagine though that it has some quirks, so you're better off using MingW or gcc if you want to avoid a bloated install of MSVC with IDE. For the record, I've never used MingW, but I assume it's good and relatively lightweight.
mingw is great. There's a bit more hassle setting it up compared to Cygwin, and it can be weird to use, but the end product is better imo
I also have used MinGW with no problems pretty much ever since I started programming in C/C++ - we use g++ at school since they have linux labs, and the newer labs have MSVC, but I've always found MinGW way nicer and smaller and less bloated than both of those (or at least simpler to install and use than Cygwin lol).
Haha it's funny to see people here on berkeley's 184 edx offering when I am in the class proper here at Berkeley.
Just finished writing the raytracer yesterday, fun project :p
On October 22 2013 07:17 Yoshi- wrote: I think the only appropriate solution to any of these problems, would be to reconsider why you would even run into them, since pretty much all of them are so absurd that they only should occur in terrible design.
First of all, a lot of people (like me) simple like solving problems like these.
Secondly, I don't know what it's like where you are from, but in Silicon Valley these types of questions come up routinely all the time in interviews for software engineering companies and at career fairs hosted by companies at universities.
In fact, the problem you were commenting about was given to me in an interview I had.
On October 21 2013 10:47 darkness wrote: I'm still trying to figure out composition in practice not theory.
So, for example:
private SomeClass sc;
// constructor public Main(SomeClass sc) { this.sc = sc; }
public int getSomeValue() { // get some value from SomeClass return sc.value; }
Is SomeClass considered part of composition?
I know this is a bit old, but it was not answered deeply enough for my taste.
Composition means that the referencing class does not only hold an instance of the referenced class but also is responsible for creating such instance(s).
Your example is an aggregation, where the instance of the referenced class can exist with or without the referencing instance.
Example: A room can only exist within a certain building. Therefore it would be suitable to have buildings being composed of rooms. A chair can exist within a room, but also outside of that room. Therefore it would be suitable to have a room aggregate chair(s).
On October 21 2013 10:47 darkness wrote: I'm still trying to figure out composition in practice not theory.
So, for example:
private SomeClass sc;
// constructor public Main(SomeClass sc) { this.sc = sc; }
public int getSomeValue() { // get some value from SomeClass return sc.value; }
Is SomeClass considered part of composition?
I know this is a bit old, but it was not answered deeply enough for my taste.
Composition means that the referencing class does not only hold an instance of the referenced class but also is responsible for creating such instance(s).
Your example is an aggregation, where the instance of the referenced class can exist with or without the referencing instance.
Example: A room can only exist within a certain building. Therefore it would be suitable to have buildings being composed of rooms. A chair can exist within a room, but also outside of that room. Therefore it would be suitable to have a room aggregate chair(s).
When most people talk about composition, they do not mean what you're talking about. Most people also do not talk in terms of UML, or use UML on a daily basis, so your link is also fairly irrelevant, and not indicative of what the terms mean in a non-UML context. Composition in a general software development context simply means an object that defers to other objects to achieve certain functionality, rather than inheriting and implementing that functionality itself. Whether it creates the objects its deferring to is pretty irrelevant, and in general having it do so makes the code harder to change, and especially harder to test.
On October 23 2013 09:45 adioN wrote: Okay so i got my validation to work, but is there anywhere to make it so the user does not have to press enter twice to move on to the next step?
bool bd = true; do { cout << "How many players want to play?" << endl; cin >> n; string a = to_string(n); bd = numValidate(a); cin.clear(); cin.ignore(); if (n == 0) { cout << "End of game." << endl; break; } } while (bd == false || n < 1 || n > 10);
Like after inputting a correct value, the user has to press enter again for the next prompt: How many players want to play? 1
Enter name of player: Any way to fix that?
I think cin.ignore(); is only ignoring 1 character. Use this instead: cin.ignore(numeric_limits<streamsize>::max());
Should be noted that this might only explain why there's an extra newline. If the user literally has to press enter twice, there's some extra cin >> or similar in your code which you aren't showing in your example.
It's always good to post minimal working examples when you need help. Remove all the code which doesn't affect your issue and show all the code. That way, someone can copy your code and test it themselves. Here's a minimal code example showing that there should be no extra enters pressed:
#include <iostream> using namespace std;
int main() { cout << "Hello." << endl; int a; cin >> a; cout << "Hi." << endl; }
Output, pressing once enter after writing 10: Hello. 10 Hi.
I'm interested in learning game programming. My main language is Java and I have dabbled in C++ for a while. I wouldn't say im a novice coder but I have mainly focused on Java due to studies. Should I learn Android game programming (I have already done 2D games with Swing etc...) or should I focus on C++ and learn SDL? My goal is to eventually become a game developer but I am unsure of what to focus on now? I think android is good as I can get apps out there and expand my portfolio plus it seems easier as Java is my main language? Or should I not take this detour and just focus on C++ and SDL then go into OpenGL?
On October 23 2013 16:32 v0rtex wrote: I'm interested in learning game programming. My main language is Java and I have dabbled in C++ for a while. I wouldn't say im a novice coder but I have mainly focused on Java due to studies. Should I learn Android game programming (I have already done 2D games with Swing etc...) or should I focus on C++ and learn SDL? My goal is to eventually become a game developer but I am unsure of what to focus on now? I think android is good as I can get apps out there and expand my portfolio plus it seems easier as Java is my main language? Or should I not take this detour and just focus on C++ and SDL then go into OpenGL?
Any advice is appreciated. Thanks!
I guess it depends on what you want to do. If you want to work at a company doing cellphone games, android is obviously the way to go. If you want to work on PC/Console AAA titles, C++ will probably be more important to know. Java is just not really useful for games, it's so rare to use it. I would assume most "real" commercial android games are programmed in other languages than java, such as C++.
If I were you, I would go with C++ and SFML. SDL works I guess, but SFML is just much cleaner and powerful, and modern for that matter.