Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?
You are not logged in.
Pages: 1
Directions:
Fill in the blanks to instantiate an object of the class Cat, passing to the constructor the value 12. Then call Meow method for that object.
Cat c = ___ Cat(__);
__Meow();
Can someone help me fill in the blanks?
Offline
Cat c = new Cat(12); c.Meow();
why nobody use var :'(
*u stinky*
Offline
lrussell wrote:Cat c = new Cat(12); c.Meow();
why nobody use var :'(
var cat = new Cat(0xc);
cat.Meow();
Complete variable names are always good practice.
Offline
while(true)
cat.Meow();
hehehe
Offline
while(true) cat.Meow();
hehehe
while (true) {
Thread.Sleep(100);
_connection.Send("say", "/kick gosha Meow")
Thread.Sleep(100);
_connection.Send("say", "/forgive gosha")
}
I learn fast
If you're using cat once.
(new Cat(12)).Meow();
---
Gosha wrote:while(true) cat.Meow();
hehehe
while (true) { Thread.Sleep(100); _connection.Send("say", "/kick gosha Meow") Thread.Sleep(100); _connection.Send("say", "/forgive gosha") }
I learn fast
Random rng = new Random();
while(true) {
con.Send("say", "/teleport AnatolyEE {0} {1}".MelodyFormat(rng.Next(0,worldX),rng.Next(0,worldY))); // I'm too poor to use C# 6 so I just did this stupid Extension Method
await Task.Delay(20);
}
Thanks to: Ernesdo (Current Avatar), Zoey2070 (Signature)
Very inactive, maybe in the future, idk.
Offline
Gosha wrote:while(true) cat.Meow();
hehehe
while (true) { Thread.Sleep(100); _connection.Send("say", "/kick gosha Meow") Thread.Sleep(100); _connection.Send("say", "/forgive gosha") }
I learn fast
i just won't join again
roasted
Offline
XxAtillaxX wrote:lrussell wrote:Cat c = new Cat(12); c.Meow();
why nobody use var :'(
var cat = new Cat(0xc); cat.Meow();
Complete variable names are always good practice.
For things where the return type is explicit (like when instantiating) I actually generally see the use of var being used since... As I said: it's explicit, obvious.
Myself I still prefer explicit variable type declaration. When I'm not sure what type the variable was, I look at the declaration, not where it's value is actually set (since generally that's in a ton of places that don't have any obvious position), meaning that if I'd put var there, I'd still have to keep looking around.
That's also why I dislike JavaScript to a degree, since I like to know and control exactly what type the variable is from the very start.
Offline
not worrying about type declaration is why I love lua.
Thanks to: Ernesdo (Current Avatar), Zoey2070 (Signature)
Very inactive, maybe in the future, idk.
Offline
Directions
Fill in the blanks to overload the minus operator for the T class:
public ___ T ____ - (T a, T b)
{
T res = new T(a.num - b.num);
____res;
}
There's another.
Also what is "0xc?"
var cat = new Cat(0xc);
cat.Meow();
Offline
0xc is a hex value
Decimal numbers are
0 1 2 3 4 5 6 7 8 9
Hex values are
0 1 2 3 4 5 6 7 8 9 a(10) b(11) c(12) d(13) e(14) f(15)
C is equal to 12 in decimal.
So 0xC means 12
Offline
I'd highly recommend figuring these things out yourself through actual practice, you won't learn very much by getting the answers handed to you.
In any event, having the answers directly provided to you is fine as long as you're acknowledging that memory alone won't help you very far in the long run.
public override T operator - (T a, T b)
{
T res = new T(a.num - b.num);
return res;
}
or, if they accept less verbose examples,
public override T operator - (T first, T second)
{
return new T(first.num - second.num);
}
also before anyone comments, this could be done but eh, it seems dodgy
public override T operator - (T first, T second) =>
return new T(first.num - second.num);
*u stinky*
Offline
Off topic:
public override T operator - (T first, T second) => return new T(first.num - second.num);
Actually got a classmate that, once he discovered Linq and Lambda expressions, he tried to pump his code full of it.
He's the kind of dude that find something cool, throws away everything he's learned before, and tries to do everything with "this awesome thing I just discovered".
Terribly annoying...
Offline
If you're using cat once.
(new Cat(12)).Meow();
---
AnatolyEE wrote:Gosha wrote:while(true) cat.Meow();
hehehe
while (true) { Thread.Sleep(100); _connection.Send("say", "/kick gosha Meow") Thread.Sleep(100); _connection.Send("say", "/forgive gosha") }
I learn fast
Random rng = new Random(); while(true) { con.Send("say", "/teleport AnatolyEE {0} {1}".MelodyFormat(rng.Next(0,worldX),rng.Next(0,worldY))); // I'm too poor to use C# 6 so I just did this stupid Extension Method await Task.Delay(20); }
worldX and worldY is null, so it will return an error.
Vinyl Melody wrote:If you're using cat once.
(new Cat(12)).Meow();
---
AnatolyEE wrote:Gosha wrote:while(true) cat.Meow();
hehehe
while (true) { Thread.Sleep(100); _connection.Send("say", "/kick gosha Meow") Thread.Sleep(100); _connection.Send("say", "/forgive gosha") }
I learn fast
Random rng = new Random(); while(true) { con.Send("say", "/teleport AnatolyEE {0} {1}".MelodyFormat(rng.Next(0,worldX),rng.Next(0,worldY))); // I'm too poor to use C# 6 so I just did this stupid Extension Method await Task.Delay(20); }
worldX and worldY is null, so it will return an error.
then set them to something
Offline
D flat mate
Offline
Pages: 1
[ Started around 1732701040.9781 - Generated in 0.137 seconds, 12 queries executed - Memory usage: 1.65 MiB (Peak: 1.87 MiB) ]