[code]
using System.IO;
using System;
class Program
{
static void Main()
{
Char[] letters = "HeLlo wOrLD".ToCharArray();
for(int i=0; i<letters.Length; i++) {
Char letter = letters[i];
if(Char.IsLower(letter)) {
letters[i] = Char.ToUpper(letter);
} else {
letters[i] = Char.ToLower(letter);
}
}
string s = new string(letters);
Console.WriteLine(s);
}
}
[/code]
This any better?
[QUOTE=ZeekyHBomb;42572547]What language and framework are you using?[/QUOTE]
C#, and framework would be XNA 4.0 right? Sorry if that's not what a framework is, I'm still learning terms.
[code]public class Crusher : Robot
{
//declare startup variables
double gunTurnAmt = 0;
public override void Run()
{
//make gun and radar turning independent from each other
IsAdjustRadarForGunTurn = true;
//start the loop that will continue the robot going
for (; ; )
{
//turn the radar a full circle to scan for robots
TurnRadarRight(360);
}
}
public override void OnScannedRobot(ScannedRobotEvent evnt)
{
//set the turn amount to the degrees from bearing of the gun
gunTurnAmt = Utils.NormalRelativeAngleDegrees(evnt.Bearing + (Heading - GunHeading));
//turn the gun that amount
TurnGunRight(gunTurnAmt);
base.OnScannedRobot(evnt);
}
}[/code]
so this is what I have right now for a current competition.
It works fine however with one flaw in design, if the enemy robot just so happens to be moving, if I take a shot directly after moving the turret, the bullet falls short of the enemy. I'd like to add some sort of prediction of where the enemy will be, and turn the gun according to an adjustment amount.
I have access to the enemies velocity, distance, bearing, and that's about it. Even if you don't want to fully give me code and such, give me a resource to look at or a keyword to look up because my brain is stumped.
I'm having a bit of trouble with part of a Python school assignment. The assignment is to create a function that takes a function and a number which will be the passed functions first argument.
Example usage:
[code]
>>> my_function(func, number):
>>> ???
>>> def add(n, m): return n + m
...
>>> add_one = my_function(add, 1)
>>> add_one(5)
6
>>> add_one(11)
12
[/code]
If anyone could point me in the right direction it'd be very nice of you.
[editline]21st October 2013[/editline]
Something like this was what I was thinking, but it gives an error because it expects two arguments.. I want the generated function to only take one argument like in the example above..
[code]
def my_function(func, number):
return lambda number, m : func(number, m)
Traceback (most recent call last):
File "Lab5.py", line 10, in <module>
print(add_one(3))
TypeError: <lambda>() missing 1 required positional argument: 'number'
[/code]
[editline]21st October 2013[/editline]
Alright so I figured it out. I was of course only supposed to give one argument to the lambda..
[code]
def my_function(func, number):
return lambda m: func(m, number)
[/code]
[QUOTE=xExigent;42589113]C#, and framework would be XNA 4.0 right? Sorry if that's not what a framework is, I'm still learning terms.[/QUOTE]
Yes, these sound correct.
[url=http://stackoverflow.com/questions/9712932/2d-xna-game-mouse-clicking]This SO-answer[/url] explains a possible approach, if checking against a rectangle is enough.
[QUOTE=esalaka;42588265]Unless C# has particularly smart string concatenation I would rather output to another char array first and convert that to a string.
[editline]21st October 2013[/editline]
Actually, can't you modify the array in-place?[/QUOTE]
It's extremely slow in C# due to interning. C# strings are good for most applications, but they fail horribly at manipulation and complicated Unicode.
What am I doing wrong?
[IMG]http://i.imgur.com/hUJAybE.png[/IMG]
I didn't work with c++ in a long time but try this:
Check if you are corrupting the stack by adding a "jmp $" after the call. If the program just hangs it's likely a misaligned stack.
Isn't printf a variable parameter function? You should add "add esp,0x8" or something after the call to reset the stack.
I need some good book and general advice on designing software. Usually, my work is just patching shit and fix vulnerabilities, but next week I'll be assigned make the spec and design for pretty big soft. I have tried making large projects in my free time and they all turn into big mess, because my initial estimation and prototypes are always off.
[QUOTE=Felheart;42594455]I didn't work with c++ in a long time but try this:
Check if you are corrupting the stack by adding a "jmp $" after the call. If the program just hangs it's likely a misaligned stack.
Isn't printf a variable parameter function? You should add "add esp,0x8" or something after the call to reset the stack.[/QUOTE]
Neither works.
Adding "add esp,8" or "jmp $" after the function call will still give me 0xC0000005: Access violation error.
Edit:
It crashes when trying to call printf, It doesn't jump to the real function but to some garbage address instead, wonder what might be causing that.
[QUOTE=uint64;42595491]I need some good book and general advice on designing software. Usually, my work is just patching shit and fix vulnerabilities, but next week I'll be assigned make the spec and design for pretty big soft. I have tried making large projects in my free time and they all turn into big mess, because my initial estimation and prototypes are always off.[/QUOTE]
What I usually do start from the top and then "delegate" things into methods or .dlls. If you do that in pseudo-code, you should be able to see where parts can be reused.
If I work on an application, I start with the UI and then implement the rest after the buttons are there. (Incrementally, I usually don't create the whole UI at once.)
It may be not the best solution for your project though. I split mine into a ton of reusable libraries that only do one thing to keep the dependency graph simple. It works for me because I reuse them all the time but it could increase the workload in your case. It's also possibly not what people are used to and would take some convincing. (Definitely factor in things like personal issues or resistance if there's a team!)
[QUOTE=ollie;42594361]What am I doing wrong?
[IMG]http://i.imgur.com/hUJAybE.png[/IMG][/QUOTE]
[B]"call printf"[/B]
should be
[B]"call ds:[printf]"[/B]
since printf is an import.
Also just checked what happens when you compile with /MT. The VC++ compiler will compile "call ds:[printf]" as "call printf" when its not an import.
[QUOTE=high;42597454][B]"call printf"[/B]
should be
[B]"call ds:[printf]"[/B]
since printf is an import.
Also just checked what happens when you compile with /MT. The VC++ compiler will compile "call ds:[printf]" as "call printf" when its not an import.[/QUOTE]
Oh I see, huge thanks!
*Snip*
Yeah, that doesn't make much sense.
That expression (char1.equals('.') || ...) would evaluate to a boolean (either true or false) and .. that's it. Do nothing. Carry one, next instruction.
Do you want to ensure that? Either check that with an if and throw an exception if the condition does not hold, or do an assert (which you explicitly need to enable when invoking the java executor, iirc --enable-asserts or -ea).
Also, use [noparse][code]/*...code...*/[/code][/noparse] to generate fancy code boxes:
[code]/*...code...*/[/code]
Been trying to implement insertion sort in Python, it has a key argument because it needs to be able to handle tuples, ex: [code]insertion_sort(db, key=lambda x : x[0])[/code]
[code]
def insertion_sort(db, key=lambda x : x):
for index in range(1, len(db)):
value = key(db[index])
i = index
while i > 0 and key(db[i-1]) > value:
db[i] = db[i-1]
i -= 1
db[i] = db[index]
[/code]
I just can't get it to work, and I'm not even sure why at this point
[editline]22nd October 2013[/editline]
I just don't get it...
This works for a normal list, not using the key parameter:
[code]
def insertion_sort(db, key=lambda x : x):
for index in range(1, len(db)):
value = db[index]
i = index
while i >= 0 and value < db[i - 1]:
db[i] = db[i - 1]
i -= 1
db[i] = db[index]
[/code]
but using the key parameter this doesn't:
[code]
def insertion_sort(db, key=lambda x : x):
for index in range(1, len(db)):
value = key(db[index])
i = index
while i >= 0 and value < key(db[i - 1]):
db[i] = db[i - 1]
i -= 1
db[i] = db[index]
[/code]
So im doing an assignment with the following requirements:
The program prompts the user to enter a valid three digit
double literal, and checks to make sure the input works.
Requirements:
1. Consists of exactly three of the following characters: +, -, . (decimal point), and 0 through 9.
2. The + or - character may only appear (once) as the first character.
3. The . (decimal point) character must appear exactly once,as either the first, second, or third character.
4. All other characters must be the 0 through 9 characters
[COLOR=#FF0000]
EDIT:[/COLOR]
Heres what i currently have.
[url]http://i.imgur.com/HIxIoGJ.png[/url]
The problem im having is that the code is not checking everything properly. To my understanding the first IF should be checking for a + or -, then if it has a decimal, then if the last char is between 0 and 9.The second IF should be checking if the first char is a decimal, and if it is it checks if the next 2 chars are between 0-9.
However, when i run my program, i can type in even "..." and it still says " ... is a valid 3 character double literal.
Do i have to nest these two IF trees together?
I've come to the point where I have no idea what to do. I'd like to work on a moderate to large sized project but I can't really come up with anything. I've rarely come across this problem before and I want to see if anyone else has any good ideas that they aren't going to do themselves.
So do you guys have anything that you wish someone would make but don't have the time or patience to do so yourself?
[QUOTE=karl1k;42599057]Been trying to implement insertion sort in Python, it has a key argument because it needs to be able to handle tuples, ex: [code]insertion_sort(db, key=lambda x : x[0])[/code]
[code]
def insertion_sort(db, key=lambda x : x):
for index in range(1, len(db)):
value = key(db[index])
i = index
while i > 0 and key(db[i-1]) > value:
db[i] = db[i-1]
i -= 1
db[i] = db[index]
[/code][/QUOTE]
Just a small mistake: the last line should be [i]db[noparse][i][/noparse] = value[/i]. [i]db[index][/i] gets overwritten by the first iteration of the while-loop, which is why you cache it in the variable [i]value[/i].
[QUOTE=PyRe;42600612]So im doing an assignment with the following requirements:
The program prompts the user to enter a valid three digit
double literal, and checks to make sure the input works.
Requirements:
1. Consists of exactly three of the following characters: +, -, . (decimal point), and 0 through 9.
2. The + or - character may only appear (once) as the first character.
3. The . (decimal point) character must appear exactly once,as either the first, second, or third character.
4. All other characters must be the 0 through 9 characters
[COLOR=#FF0000]
EDIT:[/COLOR]
Heres what i currently have.
[url]http://i.imgur.com/HIxIoGJ.png[/url]
The problem im having is that the code is not checking everything properly. To my understanding the first IF should be checking for a + or -, then if it has a decimal, then if the last char is between 0 and 9.The second IF should be checking if the first char is a decimal, and if it is it checks if the next 2 chars are between 0-9.
However, when i run my program, i can type in even "..." and it still says " ... is a valid 3 character double literal.
Do i have to nest these two IF trees together?[/QUOTE]
The code seems to look fine. I suggest you place some printlns in the if-branches, to seee which branch causes "..." to be accepted.
Also please post the code in code-tags and not as image.
[QUOTE=reevezy67;42605589]I've come to the point where I have no idea what to do. I'd like to work on a moderate to large sized project but I can't really come up with anything. I've rarely come across this problem before and I want to see if anyone else has any good ideas that they aren't going to do themselves.
So do you guys have anything that you wish someone would make but don't have the time or patience to do so yourself?[/QUOTE]
An extensible hex editor where I can select some bytes and replace the display with a certain representation, like having inline ints, floats and strings of different lengths/formats.
Being able to define structs with dynamic repetitions would be amazing, it would be easier to verify a reverse-engineered file format against a large number of files quickly.
The reason I haven't done it myself is that I'd have to learn a lot of low-level GUI programming for the text editor and I'm not very good at that.
I know there's an editor that can work with custom structs, but it's relatively expensive and doesn't have inline display.
A free editor with an easily readable struct format (with links between files) would be great, then I could make a program that converts those automatically to low-level C# libraries.
What is a good C++ environment I can use QT with?
So far I am trying to get QT to run on VS2012, but the compiling process either fatal errors or seems to be in an endless loop and compiles now for more then 5 hours.
QtCreator
[QUOTE=ZeekyHBomb;42606287]QtCreator[/QUOTE]
Will check that out. Hope the IDE is good.
[B]Edit:[/B]
Wait it is missing a compiler? I am too used to IDEs like Eclipse..
[quote=http://qt-project.org/doc/qtcreator-2.6/creator-tool-chains.html]MinGW is distributed together with Qt Creator and Qt SDK for Windows.[/quote]
It should come with one on Windows.
Hey, probably a stupid question or a simple Google ("Blue window border thing c#" - hmm) but what are the lovely sharp-edged, blue borders on here?
[img]http://i.imgur.com/dsYVeyR.png[/img]
I work with Visual Studio 12, winforms (what aestetic options?), windows 7. Is it a property? can it be done with Winforms, is it a different language :\
[QUOTE=Lemmingz95;42607794]Hey, probably a stupid question or a simple Google ("Blue window border thing c#" - hmm) but what are the lovely sharp-edged, blue borders on here?
[img]http://i.imgur.com/dsYVeyR.png[/img]
I work with Visual Studio 12, winforms (what aestetic options?), windows 7. Is it a property? can it be done with Winforms, is it a different language :\[/QUOTE]
That's not Winforms. That's XNA/DirectX I'm guessing (From the FPS counter).
There is a 'fixed 3D' property for some elements. Maybe try messing with that?
It's Windows 8.
You can emulate it with WPF though.
Search for Windows 8 or Metro for WPF/Windows 7. Maybe there's a solution for WinForms too.
Currently having heavy problems to get QT to load a driver to open a database.
[IMG]http://img43.imageshack.us/img43/7703/yfiu.jpg[/IMG]
Getting this problem. Googled it of course and got mixed messages. One was to build the drivers on your own the other one was to copy paste around 10 DLL files into the directory of the binary.
Building my own driver failed, horribly at that, and I missing 7 dll files. I am seriously about to give up on this whole thing...
[QUOTE=diwako;42611708]Currently having heavy problems to get QT to load a driver to open a database.
[IMG]http://img43.imageshack.us/img43/7703/yfiu.jpg[/IMG]
Getting this problem. Googled it of course and got mixed messages. One was to build the drivers on your own the other one was to copy paste around 10 DLL files into the directory of the binary.
Building my own driver failed, horribly at that, and I missing 7 dll files. I am seriously about to give up on this whole thing...[/QUOTE]
Why is this still the situation on Windows? For shame.
[QUOTE=Lemmingz95;42607794]Hey, probably a stupid question or a simple Google ("Blue window border thing c#" - hmm) but what are the lovely sharp-edged, blue borders on here?
[IMG]http://i.imgur.com/dsYVeyR.png[/IMG]
I work with Visual Studio 12, winforms (what aestetic options?), windows 7. Is it a property? can it be done with Winforms, is it a different language :\[/QUOTE]
-snip-, thought you were talking about VS winforms so nevermind
Sorry, you need to Log In to post a reply to this thread.