Computing desk | ||
---|---|---|
< May 17 | << Apr | May | Jun >> | May 19 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
When using DOS command prompt, does prefixing a command with "@" in a batch file makes the line execute without displaying it on the screen?
For example, a .BAT file that says:
@cd a:\
md a:\test
When executed in DOS the command prompt, would display (right?)
a:\>md a:\test
echo off
will stop commands from being displayed. Thus, you can put @echo off
as the first command in a batch file to avoid having to type the @ on every line. --Bavi H (talk) 07:05, 18 May 2008 (UTC)
Also, how would I get a batch file containing something like this (below) to execute properly?
cd c:\
md c:\test
cd c:\test
When I write a batch file to create a directory and then change to that just-created directory, it won't change. There won't be an error or anything and it displays the commands correctly, it just won't execute the "cd" command. It shows the command line containing it; but after execution of the file, I am still in "c:\" directory instead of the "c:\test" directory.
Thanks much, Zrs_12
c:
to change the current drive to C. --Bavi H (talk) 07:05, 18 May 2008 (UTC)Hmm, alright. I am using Windows XP command prompt, not DOS. Zrs 12 (talk) 19:15, 18 May 2008 (UTC)
Hi. my pc just recently refused to boot. when i try to power it on, the HD led and power led turn on (doesnt blink like it used to though).. the monitor doesnt wake (but am sure its working fine), and theres no 'beep' that usually happens before it does POST. I already tried removing/reinserting the components (hd, memory, dvd-drive, vc) but no luck.. I also find it curious why when i tried to power on w/ no memory in the slot it didnt even give a warning beep.. all the fans powerup (cpu, vc, case fan). Is my mother board dead? or is it something i missed?
Specs if it matters (amd 64 3200+,1gig ddr2, 1 sata hd, 1 ide hd, dvdrw)... Thanks in advance. 124.105.117.161 (talk) 04:52, 18 May 2008 (UTC)
is it 100% legal to save flickr photos in my ipod and show it to friends and relatives? Is it commercial use if I put in ipod and show to others? what other websites are 100% legal we can do like this? —Preceding unsigned comment added by 59.92.121.138 (talk) 05:34, 18 May 2008 (UTC)
I am looking for an example of a CLI which is currently in use. Also I need to understand why it has not been recoded as an object oriented system and have example of a device or system which uses that CLI. In addition I would like to know how and why it is utilized —Preceding unsigned comment added by 24.170.143.225 (talk) 15:40, 18 May 2008 (UTC)
"2 channels of PCM audio, each signed 16-bit values sampled at 44100 Hz".
16 bit = 2 bytes.
There are 2 channels so each second takes: 2 * 2 * 44,100 bytes.
80 minutes = 80 * 60 * (2 * 2 * 44,100) bytes = 846,720,000 bytes = 807.495117 MB > 700MB.
As far as I know CD Audio standard use no compression at all. —Preceding unsigned comment added by 89.0.235.64 (talk) 17:20, 18 May 2008 (UTC)
Suppose I have a Java class called Animal
and a bunch of subclasses of Animal
called Tiger
, Crocodile
, Monkey
, and so on. I also have a Java class called Zookeeper
. The Zookeeper
class looks something like this:
public class Zookeeper {
public void putInCage(Animal a) {
GenericCage cage = new GenericCage();
cage.insert(a);
}
public void putInCage(Tiger t) {
t.sedate();
TigerCage cage = new TigerCage();
cage.insert(t);
}
public void putInCage(Crocodile c) {
c.addMuzzle();
CrocodileCage cage = new CrocodileCage();
cage.insert(c);
c.removeMuzzle();
}
public void putInCage(Monkey m) {
MonkeyCage cage = new MonkeyCage();
cage.insert(m);
m.feed(new Banana());
}
// etc.
}
Now, somewhere else in my code I am given an Object
. This may or may not be an Animal
(and if it's an Animal
, it might be a Tiger
or a Crocodile
or a Monkey
or what have you, or it might just be a plain old Animal
). If it is an Animal
, then I want to have my zookeeper put it in a proper cage. So I tried something like this:
public void process(Object o) {
if (o instanceof Animal) {
zookeeper.putInCage( (Animal) o );
}
}
I have to cast o
to an Animal
, because the zookeeper doesn't have a putInCage(Object)
method. The problem is that this casting always causes the generic putInCage(Animal)
method to be called, even if o
is actually a Tiger
or a Crocodile
or a Monkey
, so these animals are put into cages incorrectly.
I don't want to have to include a whole bunch of lines like if (o instanceof Tiger)
, because there are too many subclasses of Animal
, and more might be added in the future—and anyway it seems that I shouldn't have to do that (isn't that what method overloading is for in the first place?). How do I get around this problem? —Bkell (talk) 23:41, 18 May 2008 (UTC)
(Animal) o
has type Animal. You have to explain what you are doing with these "cages" in more detail, because from the code you've posted, it appears that you create a new kind of cage, and then discard it, in each method, so it's not doing anything; I'm assuming that this is not your complete code. What is the difference between these "cages"? And how are these "cages" used outside of the method? From what you are saying about not wanting the Zookeeper keep track of the types of subclasses, another possibility, depending on what you want to do, might be to have a method in Animal that is executed when it is to be put in a cage. Then subclasses of Animal can override the method and implement custom behavior. Then each type of animal would have to contain the intelligence about what is to be done to it. Is that what you want? --Spoon! (talk) 00:47, 19 May 2008 (UTC)Animal a = new Tiger();
zookeeper.putInCage(a);
Animal
. (Try this if you don't believe me.) The same thing works if I wrap it in a method:public void process(Animal a) {
zookeeper.putInCage(a);
}
Object
s is because I have to explicitly cast the Object
to an Animal
to be able to call putInCage()
at all, but the compiler interprets this as a request to use putInCage(Animal)
regardless of the actual type of the animal.Animal
do the putting-in-cages themselves. In my actual code things are more complicated, and in fact the zookeeper himself is an Animal
(and how the put-in-cage operation should be done depends on the type of the zookeeper as well as the type of the animal), so this solution doesn't work—there is no "other" class to which the methods can be moved (or, to think about it another way, if the methods are moved to the individual subclasses of Animal
, then the arguments change to reflect different types of Zookeeper
, so you haven't gained anything). I can explain the whole situation in great detail if you like, but I think it would needlessly introduce a whole bunch of complexity. I tried to simplify the situation as much as I could, so if you can just take it on faith that it doesn't make sense to move the methods out of the Zookeeper
class. —Bkell (talk) 01:03, 19 May 2008 (UTC)Animal a = new Tiger();
zookeeper.putInCage(a);
putInCage(Animal)
method which is being called, not the putInCage(Tiger)
method. It seems I will have to concede that overloading is done at compile time, as you said, Spoon. I think that means I need to go ponder my new perspective on the Java method calling mechanism. —Bkell (talk) 01:23, 19 May 2008 (UTC)"Overloading considered harmful" seems to address a lot of my misunderstandings. I'll read through it carefully and then maybe I can formulate a better model of my problem. —Bkell (talk) 02:00, 19 May 2008 (UTC)
public void cage(Zookeeper z) { z.putInCage(this); }
into Animal and each subclass of Animal (it needs to be overridden) then call it from Zookeeper with (Animal) o.cage(this);
. It avoids casting, so it sidesteps the problem. But not in an elegant way. :) - Bilby (talk) 11:57, 19 May 2008 (UTC)(edit conflict) But, as we all know, casting (not to mention everything else) in C++ is way too complicated. The standard Java pattern is, as Spoon said, to use overriding:
public class Animal {
public void putInCage() {
GenericCage cage = new GenericCage();
cage.insert(this);
}
}
public class Tiger extends Animal {
@Override
public void putInCage() {
sedate();
TigerCage cage = new TigerCage();
cage.insert(this);
}
}
// etc...
Then you can completely eliminate the Zookeeper
class, or at least the Zookeeper.putInCage()
methods. It's much prettier, and it allows clients to create their own putInCage()
methods for their classes. « Aaron Rotenberg « Talk « 02:38, 19 May 2008 (UTC)
public class Zookeeper {
public void putInCage(Animal a) {
if (a instanceof Tiger) {
putInCage((Tiger)a);
} else if (a instanceof Crocodile) {
putInCage((Crocodile)a);
} else if (a instanceof Monkey) {
putInCage((Monkey)a);
} else {
GenericCage cage = new GenericCage();
cage.insert(a);
}
}
...
}
public class Zookeeper {
public void putInCage(Animal a) {
a.prepareForCage();
a.createCage().insert(a);
a.accommodateToCage();
}
}