Rashakil Fol 978 Super Senior Demiposter Team Colleague

Well clearly, the matrix manipulation class should provide clear error messages, throwing exceptions when you try to do impossible things. What do you expect integers to do when you divide by zero? Would you rather report an array out of bounds exception or have a clearer exception that explains that the matrices are of the wrong dimensions?

So the matrix class should throw the exception, and either the user interface should avoid adding mismatched matrices in the first place, or, if you like, catch the matrix class's exception and report the error. You'd probably want a special subclass of InvalidOperationException that users of the matrix can catch to handle errors with their matrices, rather than an internal error in the program.

Regarding cars and garages -- well, who has what responsibility depends on how you're representing the physical universe.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Often I want to downrep somebody for being dumb, but them uprep them somewhere else to cancel out the downrep I just gave, because I'm not trying to be mean. But I can't! Please change things so that this can be done. One way is to limit the user to two reps per person per day. Another would be to allow somebody to rep another twice within 24 hours as long as the previous rep was in the opposite direction.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I'm not that exceptional of a math student, and I've been told that Information Technology requires less math then a CS degree.

Are you having trouble with the math in your CS classes, or are you speculating that you might have trouble?

What worries me though is how far a degree in IT would get me compared to a CS degree.

They point in different directions.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Then why are you trying to get a ReadLine property off of a method group? That makes no sense.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Define 'provider' and define 'consumer'. What do you mean by 'putting a car in a garage'? That analogy can mean different things. (Maybe just tell us what you're doing.)

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You're going to have to give more information. What is the type of Input?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Thanks, but just to recap, my question is: Is it possible to create a data type which is not bounded to predefined C++ data types. I can create my own classes. but that would still rely on them. ( int, char, double whatever.. ). E.g.: what If I want to create a 6000 byte long number? ( I know, it would be insane, but just for the sake of curiosity.)

What the fuck is wrong with you? The mechanism for creating datatypes in C++ is classes. Why wouldn't you use classes?

In the future, please keep your insanity to yourself. The insanity isn't wanting a 6000 byte number, it's asking how to create datatypes when the mechanism for creating datatypes is staring you in the face.

I'm being mean. If you wanted to create a 6000 byte long number, you would do something like this:

class int6000 {
    uint32_t data[1500];
  public:
    // ...
};

uint32_t is not a C++-standard type, I don't think, so substitute whatever 4-byte integer type you want if it doesn't work on your compiler (try #include <limits.h> to make uint32_t available).

Rashakil Fol 978 Super Senior Demiposter Team Colleague

If you want a job in America, they'll have heard of Oxford but not Imperial.

(And that's just my mindframe because all my british coworkers are working in America :))

Rashakil Fol 978 Super Senior Demiposter Team Colleague

It is always okay to expose public fields when the purpose of a class is to contain said field. For a tiny private data struct? Okay. For a public use-everywhere data structure? Okay. For example, it's okay for a binary tree datatype (not a binary search tree, just a plain old binary tree) to expose its fields publicly.

The question is whether you might want to switch to an implementation that is different but somehow has equal behavior. That's possible if your notion of what a datatype is depends on facts such as the way it behaves, but doesn't depend on internal implementation. On the other hand, if the notion of what your datatype is depends solely on what it contains, or partly so, then your fields or some of your fields should be publicly exposed. For example, the notion of a DateTime does not depend on what it contains, so there's no reason you'd want to expose your internal implementation. On the other hand, the notion of a point in a plane is that it's a pair of real numbers.

Josh Bloch's example should be regarded as a parody of his opinion. His mention of the Dimension class was a byproduct of the fact that the fields were mutable, not the fact that they were publicly exposed, as he claims.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You mean pass in arrays of numbers? Yes, use arrays.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

And I would expect using Input.ReadLine to get you an error about a type mismatch, so maybe you meant Input.ReadLine().

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What is the ctr? What are you talking about.

You should regard this as a problem of approaching the list from one of three cases: the previous element having been a list, having been an atom, or none of the above. If you face the problem by writing three separate functions for each of these situations, you can easily and readably solve this problem recursively.

This scheme is incredibly hard for me for some reason.

The reason is that you suck at programming, a fact stated objectively because you're having trouble with this assignment. The good news is that this course might correct some of that.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Start by learning how ASP works.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Input.ReadLine()?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Your question makes no sense -- ArrayList is already in .NET 1.1.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Yes for some of them. You can read the DrScheme documentation to find out what they are. For the others, you can obviously write your own implementation using the functions cons, null?, car, and cdr.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Because I needed 0.

You're mistaking zero for Zorro. Get it right.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Well, Partition can clearly return an array. And you can obviously alter the array that it returns. And you can easily construct an an array. I don't understand your question.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I see that the folder icons are using solid white backgrounds rather than transparent backgrounds. The white stands out when the icons are used on a non-white background, as seen at <http://www.daniweb.com/category2.html>.

This unacceptable, and I demand that this be fixed! How can I give information when these unkempt forum icons are profaning the digital landscape with their pixels of evil on every other page I visit?

Dictated but not read,
Rashakil Fol

iamthwee commented: Off topic, I have just noticed you have a beautiful blue eye. +18
Rashakil Fol 978 Super Senior Demiposter Team Colleague

I have gotten the sense of a lot of users on this forum sharing the same mindset? Why is that :(

I agree, it seems like somehow the mindset of figuring out how to write code on your own has been transformed in this thread into the mindset of knowing all the features of a language and figuring out how it works, all while somehow being able to distinguish between good sources of information and bad sources of information without having the knowledge needed to do so.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I suggest you call Partition on the tail _before_ you examine the first element of the list. Then update the array that Partition returns appropriately to account for the first element of the list. Only construct the array when Partition receives an empty list.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

In System.Linq.Enumerable.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Well, what happens when you set a breakpoint and walk through? I mean, what is Rows.Add doing?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Your first loop seemed broken, since you had the loop condition backwards. This second version seems like it should work, but it is a mystery to me.

What happens when you debug your code?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You can unzip an array like that using the Where extension method (in .NET 3.5).

int[] evenPositioned = numbers.Where((x, i) => i % 2 == 0).ToArray();
int[] oddPositioned = numbers.Where((x, i) => i % 2 == 1).ToArray();

So input them into one array and then do the disentangling.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

So don't use var, use the type name.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

It doesn't help that his code won't work in C# 3.0 either. ev is not in scope where he uses it.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Is it possible to give negative votes for people?

John A commented: Negative votes should be worth twice as much. +17
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Whatever you do, don't tell us what line numbers these errors happened on.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

var is a C# 3.0 feature; it can't possibly work with a C# 2 compiler.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You have syntax errors. Read through the code character by character and get rid of the syntax errors.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

I need assistance with the following excercise:

Why do you need assistance?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The danger lurks because the pointer could be null, or the pointer could be pointing at something that no longer exists. It's easy for programmers to make mistakes like that. It's slightly harder to do this with references. Also, there ends up being less syntax involved, and the person using the function doesn't have to wonder whether the argument may be a pointer to an array.

The reason the first const is used in that code example (in const sVec4& other ) is because that means the function is promising not to modify the value of 'other'. It receives a reference to the variable and promises not to modify it (and if a developer accidentally tried to do so later, the code wouldn't compile). There are other de facto agreements too -- because the variable's passed by reference, the function won't do anything that assumes the variable exists after it has returned. I mean, it could, but that would look weird and the programmer would have to be really drunk to do such a thing.

The reason for the second const, that goes after the argument list, is to promise that the function dot_xyz won't modify the object it's called with. Suppose the function dot_xyz is a member of the class X. If you had a const X lying around somewhere, you would not be able to call the member function dot_xyz if it didn't have that const declaration.

The reason const declarations are useful is because …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The trigonometric functions expect their arguments to be in radians. Your input expects values in degrees. (PI/2)*(180/PI) is kind of funny; it simplifies to 90...

Rashakil Fol 978 Super Senior Demiposter Team Colleague

It's the same thing -- once the code has been compiled -- and used for the same purpose. It's better to use the second way, passing "by reference," because the first desensitizes you toward pointers. (Your spidey sense should tingle when you see a pointer -- it means danger lurks.)

It's very common, especially, for functions to take arguments passed by a const reference.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

There's no "**" operator in Java. Either use Math.pow or write your own squaring function.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

There's a DateTime constructor that takes year, month, day, hour, minute, second.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

is there any c++ equivalent of doing that?

Nope :)

cikara21 commented: ok.. +1
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Trying to make a circular queue, but its not working right. Enqueue is just adding things to the end, every time.

my output is:
Numbers in Queue: 1 2 3
Numbers in Queue: 2 3
Numbers in Queue: 2 3 6

it should be:
Numbers in Queue: 1 2 3
Numbers in Queue: 2 3
Numbers in Queue: 6 2 3

any suggestions?

That's the way your queue is supposed to work -- its capacity is 5, not 3.

My main suggestions have to do with coding style. Don't have the return type be object if you only return a bool; return void if you're going to return the same bool every time; don't name separate functions Empty and empty because that's retarded; use capital names for all your functions because that's C# style; use lowercase names for private variables because that's C# style; whatever naming scheme you use, be consistent because that's convenient; in functions, avoid declaring variables without initializing them if you have no reason to do so, it just makes the code take more brain capacity to read that way; don't write x++; return (x); , just write return x + 1; ; don't write tail == 5 , write tail == Qlist.Length , because your code is more resilient that way; name your function "IsEmpty" instead of "Empty" because that's more clear, and rename "empty" to "Clear" because that's more Clear; have your function "empty" make it so that …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Start with making or using a parser, then... finish with making an algorithm that analyzes.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Where's the source code!

Rashakil Fol 978 Super Senior Demiposter Team Colleague

It would be a cool forum; I think it would be somewhat outside the scope of Daniweb. If you find such a forum that you like, please tell me about it in this thread.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Things are case-sensitive in Java.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

A struct defines a value type; a class defines a reference type.

A value type is one whose values cannot be separated from the variable. If you try copying it to a different variable, you'll make a complete copy. You don't really modify value types -- you modify the variables that contain them.

Compare this with class types, where variables contain references that point to objects -- where two variables of that type may contain references that point to the same object.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Also, there's the option of inlining the code, so that you don't incur the cost of a function call (which seems to me like it would be a problem in Python).

No seriously, write this performance-intensive part in C.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

It's not necessary to right-shift a value immediately before you multiply it by a constant. So:

def luminance(pixel):
    """Calculate and return the luminance of a pixel."""

    return 0.299 * (pixel & 0xFF) + 0.002293 * (pixel & 0xFF00) + .00000174 * (pixel & 0xFF0000)

I assume removing the doc comment doesn't help, but maybe you shouldn't.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Write it in C.

Edit:
Well, for starters,

g = (pixel >> 8) & 255;
Rashakil Fol 978 Super Senior Demiposter Team Colleague

And that's an easy decision: you want TCP, unless you specifically don't.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Is it to use sockets, or to use something more TCP based?

Something "TCP-based" does use sockets.

Take a look at System.Net.Sockets, you probably just want to use TcpClient and TcpListener, and maybe you'll get better advice regarding a secure connection, but that probably involves using something in System.Net.Security

Rashakil Fol 978 Super Senior Demiposter Team Colleague
enter region = O;
enter commodities = 2;
enter saler = 1;
prise = 500$;

What does this code even mean? It is not C#.