Hello, World!
class Main {
static void Main() {
console.log("Hello, World!")
}
}
Class and OOP system
class Item {
public string name;
public Item(string name) {
this.name = name;
}
}
// You can inherit a class like this
class Weapon : Item {
public float damage;
public Weapon(float damage, string name) : base(name) {
this.damage = damage;
}
void dealDamage() {
console.log(`Your ${name} deals ${damage} damage`)
}
}
class Consumable : Item {
public int useTime;
public Consumable(int useTime, string name):base(name) {
this.useTime = useTime;
}
void consume() {
console.log(`You consumed`)
}
}
// You can also inherit multiple classes
class ThrowingWeapon : Consumable,Weapon {
public float speed;
public ThrowingWeapon(float speed, int useTime, string name, float damage):base(useTime, name, damage) {
this.speed = speed;
}
}
Copyrights © 2021 Cassidy
This project is licensed under the GNU GPLv3 License