What would he do if it were floats?
-
Found in an article approved not too long ago... And no, I didn't throw out case 5.
public int Volume
{
get { return this.volume; }
set
{
if (value < 0) { this.volume = 0; }
else if (value > 10) { this.volume = 10; }
else { this.volume = value; }// Set it on Windows Media Player // Fix up switch ( this.volume ) { case 0: this.volume = 10; break; case 1: this.volume = 9; break; case 2: this.volume = 8; break; case 3: this.volume = 7; break; case 4: this.volume = 6; break; case 6: this.volume = 4; break; case 7: this.volume = 3; break; case 8: this.volume = 2; break; case 9: this.volume = 1; break; case 10: this.volume = 0; break; } this.volume = this.volume \* -100; this.player.Volume = this.volume; //System.Windows.Forms.MessageBox.Show(this.player.Volume.ToString());
}
}Regards, mav -- Black holes are the places where God divided by 0...
-
Found in an article approved not too long ago... And no, I didn't throw out case 5.
public int Volume
{
get { return this.volume; }
set
{
if (value < 0) { this.volume = 0; }
else if (value > 10) { this.volume = 10; }
else { this.volume = value; }// Set it on Windows Media Player // Fix up switch ( this.volume ) { case 0: this.volume = 10; break; case 1: this.volume = 9; break; case 2: this.volume = 8; break; case 3: this.volume = 7; break; case 4: this.volume = 6; break; case 6: this.volume = 4; break; case 7: this.volume = 3; break; case 8: this.volume = 2; break; case 9: this.volume = 1; break; case 10: this.volume = 0; break; } this.volume = this.volume \* -100; this.player.Volume = this.volume; //System.Windows.Forms.MessageBox.Show(this.player.Volume.ToString());
}
}Regards, mav -- Black holes are the places where God divided by 0...
mav.northwind wrote:
no, I didn't throw out case 5.
Why would you? Anyone can see it isn't necessary and the original author has optimised it out for efficiency reasons. :laugh:
-
Found in an article approved not too long ago... And no, I didn't throw out case 5.
public int Volume
{
get { return this.volume; }
set
{
if (value < 0) { this.volume = 0; }
else if (value > 10) { this.volume = 10; }
else { this.volume = value; }// Set it on Windows Media Player // Fix up switch ( this.volume ) { case 0: this.volume = 10; break; case 1: this.volume = 9; break; case 2: this.volume = 8; break; case 3: this.volume = 7; break; case 4: this.volume = 6; break; case 6: this.volume = 4; break; case 7: this.volume = 3; break; case 8: this.volume = 2; break; case 9: this.volume = 1; break; case 10: this.volume = 0; break; } this.volume = this.volume \* -100; this.player.Volume = this.volume; //System.Windows.Forms.MessageBox.Show(this.player.Volume.ToString());
}
}Regards, mav -- Black holes are the places where God divided by 0...
How about:
this.volume = 10 - this.volume;
Or is that too verbose?
mav.northwind wrote:
this.volume = this.volume * -100;
So, first prevent setting the volume to any value lower than 0 and than set it way below 0 every time?
mav.northwind wrote:
this.player.Volume = this.volume;
Good job causing an endless recursion... X|
-
How about:
this.volume = 10 - this.volume;
Or is that too verbose?
mav.northwind wrote:
this.volume = this.volume * -100;
So, first prevent setting the volume to any value lower than 0 and than set it way below 0 every time?
mav.northwind wrote:
this.player.Volume = this.volume;
Good job causing an endless recursion... X|
I just love the effect of
this.volume++;
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
-
Found in an article approved not too long ago... And no, I didn't throw out case 5.
public int Volume
{
get { return this.volume; }
set
{
if (value < 0) { this.volume = 0; }
else if (value > 10) { this.volume = 10; }
else { this.volume = value; }// Set it on Windows Media Player // Fix up switch ( this.volume ) { case 0: this.volume = 10; break; case 1: this.volume = 9; break; case 2: this.volume = 8; break; case 3: this.volume = 7; break; case 4: this.volume = 6; break; case 6: this.volume = 4; break; case 7: this.volume = 3; break; case 8: this.volume = 2; break; case 9: this.volume = 1; break; case 10: this.volume = 0; break; } this.volume = this.volume \* -100; this.player.Volume = this.volume; //System.Windows.Forms.MessageBox.Show(this.player.Volume.ToString());
}
}Regards, mav -- Black holes are the places where God divided by 0...