在书中我正在阅读"Head First Design Patterns",Command Pattern中有一个例子,他们用Lambda代替了Interface.
这只是Java能够做到的吗?这是一个例子
// Receiver
public class Light
{
public void On() {
Console.WriteLine("Lights on");
}
public void Off() {
Console.WriteLine("Ligts off");
}
}
// Command interface
public interface ICommand
{
void Execute();
}
// Concrete command
public class SimpleCommandLightOn : ICommand
{
private readonly Light light;
public SimpleCommandLightOn(Light light) {
this.light = light;
}
public void Execute() {
light.On();
}
}
// Concrete command
public class SimpleCommandLightOff : ICommand
{
private readonly Light light;
public …Run Code Online (Sandbox Code Playgroud) 我正在使用 bitbucket 来托管我的 git 存储库。我添加了一个名为 ExtLibs 的新文件夹并添加了一堆 dll。但是,当我尝试签入这些文件时,它们不会出现在 SourceTree 中。
如何将包含(dll)文件的文件夹添加到 repo?
我从这里使用 .gitignore (c#/VS2013)
你什么时候使用其中一个?
public interface IFriendly
{
string GetFriendly();
}
public abstract class Person: IFriendly
{
public abstract string GetFriendly();
}
Run Code Online (Sandbox Code Playgroud)
VS.
public interface IFriendly
{
string GetFriendly();
}
public abstract class Person
{
// some other stuff i would like subclasses to have
}
public abstract class Employee : Person, IFriendly
{
public string GetFriendly()
{
return "friendly";
}
}
Run Code Online (Sandbox Code Playgroud)