This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IMovable { | |
void Move( Vector3 direction ); | |
} | |
public abstract class Animal : IMovable { | |
// 雖然宣告實作了介面,但仍然可以利用abstract將此工作交給繼承的類別 | |
public abstract void Move( Vector3 direction ); | |
} | |
public class Bird : Animal { | |
// 繼承了抽象類別,就必須實作所有的抽象方法 | |
public override void Move( Vector3 direction ) { | |
// 在這裡寫下方法的定義 | |
} | |
} | |
public struct Vector3 { | |
public float x; | |
public float y; | |
public float z; | |
public Vector3( float x, float y, float z ) { | |
this.x = x; | |
this.y = y; | |
this.z = z; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment