Jump to content
  • Advertisement

Fred304

Member
  • Content Count

    388
  • Joined

  • Last visited

Community Reputation

382 Neutral

About Fred304

  • Rank
    Member
  1. Quote:Original post by ShauwnBlue I'm trying to think of how I can order objects based on an instance variable in each one. Have the class implement the Comparable interface. In the compareTo method, compare the instance variable. Then you should be able to sort a collection containing Tasks.
  2. Fred304

    Interger wrap around? Really a caution?

    Quote:Original post by benryves I'd actually say the easiest method would be: You can do it simpler without a loop: int CurrentRings = 0; int CurrentLives = 3; void AddRings(int count) { CurrentRings += count; CurrentLives += CurrentRings / 100; CurrentRings = CurrentRings % 100; }
  3. Fred304

    (Solved) Loop not looping

    Yeah, Chad Smith and person above him are right. Just use while (true).
  4. Fred304

    Carked it

    If you need advice as to what you can do with your life, solve Monkey Island 2.
  5. Fred304

    OOP class problems

    You have a circular dependency between the script class and the GUI class -> bad design.
  6. Fred304

    (Solved) Loop not looping

    You don't need b. Simply write: while (true) { // ... } or for (;;) { // ... }
  7. Quote:Original post by BoSoft Unfortunately I don't know of any free tools to measure them. Metrics Plugin for Eclipse
  8. Quote:Original post by rsl developer So how can I tell??? Two criteria for a good design: - high encapsulation (ideally, no class knows about other classes' implementations) - low cohaesion (ideally, every class has exactly one responsibility)
  9. Fred304

    Program Structure/Theory

    Quote:Original post by GTspeed [...] a class or an object? The relationship between class and object is similar to that between integer and 5. You have an abstract idea of what you can do with every integer (for example you can add two integers together), and 5 is one specific example of an integer (so you are allowed to add it to 7). When you write classes, you think about what all instances of this class share. For example, every person has a specific height, weight, eyecolor etc. The purpose of the class is to define these properties. The instances of this class have unique values assigned to these properties (for example, one person might be taller than another, in this sense these values are unique - but these two people still share the concept of having a height, that's what's common to them).
  10. Fred304

    Optimize count algoritm

    You could use an int array of size 2^24 which takes up 64 MiB of memory and use the rgb-color as an index into that array. int[] count = new int[2^24]; fill count with zeros; foreach color in picture ++count[color]; int unique = 0; foreach c in count if (c > 0) ++unique; delete[] count; BTW you don't need the if in the operator<, just return the expression immediately: bool operator<(const rgb a) const { return (r < a.r); }
  11. Fred304

    Inheritance and methods

    Quote:Original post by Crazyfool So my question is, is there a way the method can accept a Card object, and then process everything individually? The right way to do this is to have a virtual manage method in the base class and override it in the subclasses, so that every kind of card can manage itself.
  12. Fred304

    Interface Design [SOLVED]

    Quote:Original post by Glak My original implementation used virtual functions. My current implementation uses gotos. Jehova!
  13. Fred304

    Shuffling of a card deck.

    Quote:Original post by JohnBolton Here is a simple, efficient, and effective algorithm: for i = 0 to 51 r = random number between i and 51, inclusive swap deck[ i ] and deck[ r ] That's how Java shuffles, so I guess it's a well accepted algorithm. (Collections.shuffle)
  14. Fred304

    designing the enemy class

    Quote:Original post by password I thought there would be some conflict because they were different classes if I were to store them into an std::vector. You are right, it is not possible to store objects of different classes in a vector, because they might have different sizes. However, you can store polymorphic pointers to objects of different classes, because they all have the same size.
  15. Codesize is orthogonal to execution time, they do not corelate. This means that more code can be both slower or faster then less code. (An example for more code that is faster: loop unrolling.)
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!