User | Post |
pragma7
 
   

  
 
 
Since: 04-26-02 From: USA, NJ
Since last post: 8170 days Last activity: 8183 days
|
|
hehe...
switch(target) {
case "squirrel":
setWeapon(pellet_gun);
shootTarget(target);
if (!targetDead(target))
return;
else
break;
case "arv1328":
setWeapon(blunt_object);
poundTarget(target);
if (!targetDead(target))
return;
else
break;
}
... Rob |
MingShun
 
   

  
 
 
Since: 05-10-02 Rating: 10 (400 pts)
Since last post: 7747 days Last activity: 7747 days
|
|
hmm...something seems wrong about pragma's code...maybe not efficient enough...
BTW, what does 'return' in a switch statement do?
-------------------- I'm an archer, and an acolyte. Wish I could change between characters while in game. |
Makoto
Moderator
 
   


  
 
 
Since: 02-19-02 From: England
Since last post: 8107 days Last activity: 8094 days
|
|
bleh, all your codes are far to innefficiant, all you need is:
(the file is named Main.java)
class Main {
public static void Main(String[] args) {
Person nastyPerson = new Person();
kill(nastyPerson);
}
private kill(Person target) {
for (moveTo(target.location); beatWithPointyStick(target); !target.isDead) {};
disposeOf(target);
}
private beatWithPointyStick(Person target) {
//this is far to long and complex, and im sure you know how
}
private disposeOf(Person target) {
//this too is too long
}
}
ok, so thats technicly longer then yours, but mine will acctually compile (well, if the object included acctually exsited as classes (eg 'Coordinate' and 'Person'))
EDIT: (some minor adjustments)
(edited by Makoto on 05-23-02 05:13 PM) |
Sasami
Goddess in Training
 
   


  
 
 
Since: 02-18-02 From: Back in texas! YAY! college sucked! Rating: 10 (1030 pts)
Since last post: 7699 days Last activity: 7699 days
|
|
His would work just fine too if he added the header and footers, it was for C. |
Makoto
Moderator
 
   


  
 
 
Since: 02-19-02 From: England
Since last post: 8107 days Last activity: 8094 days
|
|
oh, ok  |
Talien
 
   


  
 
 
Since: 05-08-02 From: Michigan
Since last post: 8320 days Last activity: 8320 days
|
|
Originally posted by Kaede_X Wonderful, that's all we need. Idiot's streaming into here...
Btw Talien, are you the very same Talien that I argued with for about an hour in Izlude? I was a mage called Jinzou.
Heh, I'm the only Talien in RO so I guess I'd have to be. Don't really remember it though, but then again I usually forget about arguments real soon afterward. |
DaiSHi
Moderator
 
   


  
 
 
Since: 05-03-02 From: California Rating: 10 (400 pts)
Since last post: 7699 days Last activity: 7699 days
|
|
please, no more java. i'm done with java for the night... i actually turned in a program that compiled and ran correctly. too bad the stupid jUnit testing was being a pain...
-------------------- Loki: DaiSHi, H.O.L.Y.Merchant, Robbin'Hood
47/34 swordman, 23/17 merc, 34/25 Thief |
Sasami
Goddess in Training
 
   


  
 
 
Since: 02-18-02 From: Back in texas! YAY! college sucked! Rating: 10 (1030 pts)
Since last post: 7699 days Last activity: 7699 days
|
|
Java is the one language I just can't stand -.- I feel that it's is a crappy rip off of c++, I can understand using it for the internet, but using it to make normal programs is silly, might as well use C. And if you want to do something on the internet, might as well do flash. |
Makoto
Moderator
 
   


  
 
 
Since: 02-19-02 From: England
Since last post: 8107 days Last activity: 8094 days
|
|
the reason why Java is used instead of C is simple... Java is free
i agree tho that Java isnt that great, mind you C++ isnt hugly nice either
i acctually quite like object pascal myself
not as powerfull as C++ tho
EDIT: oh, and Java is also very portable
(edited by Makoto on 05-24-02 08:25 AM) |
Sasami
Goddess in Training
 
   


  
 
 
Since: 02-18-02 From: Back in texas! YAY! college sucked! Rating: 10 (1030 pts)
Since last post: 7699 days Last activity: 7699 days
|
|
because something is free might make it a better option for unprofessionals, but if you want to work on this stuff professionally, go with the most powerful language. When doing stuff for money, it is better to spend more money to make even more money. |
pragma7
 
   

  
 
 
Since: 04-26-02 From: USA, NJ
Since last post: 8170 days Last activity: 8183 days
|
|
Originally posted by MingShun hmm...something seems wrong about pragma's code...maybe not efficient enough...
BTW, what does 'return' in a switch statement do?
Returns, just like is says and re-tests the condition.... in other words, if target's not dead, return and start again...and keep going untill they're dead...
Makato:
Actually, mine is more efficient;
1. OOP is an overkill for what we need, too much code, to little to do.
2. Java sucks, sorry...I hate it...If you want cross platform go Delphi.
3. It will compile faster.
4. It will run faster.
5. C is the king of languages (except when it comes to string handleing, lol)
There probably more too, but let's not go there .
BTW... Here's the C equivalent to what you did...
while(!isDead(target)) {
moveTo(target.location);
beat(target, pointy_stick);
}
Rob
(edited by pragma7 on 05-24-02 03:58 PM)
(edited by pragma7 on 05-24-02 04:20 PM) |
MingShun
 
   

  
 
 
Since: 05-10-02 Rating: 10 (400 pts)
Since last post: 7747 days Last activity: 7747 days
|
|
string handling in C++ gives me a headache. It's easy to make strings, but when you want user input...yuck.
Ah, so that's what return does. Thought it did that, but I didn't believe myself. All I used return for was exiting out of void functions...
--------------------
I'm an archer, and an acolyte. Wish I could change between characters while in game.
(edited by MingShun on 05-24-02 09:25 PM) |
Sasami
Goddess in Training
 
   


  
 
 
Since: 02-18-02 From: Back in texas! YAY! college sucked! Rating: 10 (1030 pts)
Since last post: 7699 days Last activity: 7699 days
|
|
nuts to strings! An array of chars is the way to go!  |
pragma7
 
   

  
 
 
Since: 04-26-02 From: USA, NJ
Since last post: 8170 days Last activity: 8183 days
|
|
or...
char *string[MAX_STRINGS};
Those are always fun...
return can also return a value from a function...as in..
void main() {
int NumA, NumB = 0;
printf("Enter the first number: ");
scanf("%d", NumA);
printf("\nEnter the second number: ");
scanf("%d", NumB);
// And of corse, the third integer in our string is returned by calling GetSum()
printf("\n\nThe sum of %d and %d is %d.", NumA, NumB, GetSum(NumA, NumB));
}
int GetSum(sNumA, sNumB) {
int Sum = 0;
Sum = sNumA + sNumB;
return Sum;
}
See? The return statement can be very useful
Rob
(edited by pragma7 on 05-25-02 12:21 AM) |
Makoto
Moderator
 
   


  
 
 
Since: 02-19-02 From: England
Since last post: 8107 days Last activity: 8094 days
|
|
Originally posted by Sasami because something is free might make it a better option for unprofessionals, but if you want to work on this stuff professionally, go with the most powerful language. When doing stuff for money, it is better to spend more money to make even more money.
i completely agree, i also thinnk that more companies should use object pascal, its a very nice and tidy language, only problem is it cant do quite as much as C++, but its still a very nice program language
EDIT: (couldn't post two in a row, heh)
Originally posted by pragma7
Originally posted by MingShun hmm...something seems wrong about pragma's code...maybe not efficient enough...
BTW, what does 'return' in a switch statement do?
Returns, just like is says and re-tests the condition.... in other words, if target's not dead, return and start again...and keep going untill they're dead...
Makato:
Actually, mine is more efficient;
1. OOP is an overkill for what we need, too much code, to little to do.
2. Java sucks, sorry...I hate it...If you want cross platform go Delphi.
3. It will compile faster.
4. It will run faster.
5. C is the king of languages (except when it comes to string handleing, lol)
There probably more too, but let's not go there .
BTW... Here's the C equivalent to what you did...
while(!isDead(target)) {
moveTo(target.location);
beat(target, pointy_stick);
}
Rob
1. heh, well, i lernt to program in OOP, my Uni's computer lecturers are kind obsessed with OOP
2. i agree, i dont like Java much either, but thats what i lernt
oh, and i lernt delphi in the previous year, now THERES a nice development evironment, and it uses oject pascal, which you may have seen my say i rather like
and my end of year Java project would have been done in an hour if they'd let me do it in delphi, but nooooo i had to do it in Java -.-
3. indeed, true
4. yup, heh, altho it wont auto destroy unused objects
5. bah, no, pascal is better , even if it is less powerfull
(edited by Makoto on 05-25-02 06:49 AM) |
Doomcraft
 
   


  
 
 
Since: 04-28-02 From: Portugal
Since last post: 8319 days Last activity: 8308 days
|
|
I like C, simple to use once you get used to it and very powerfull.
-------------------- And once again our friend, and semi-hero posts again....
|