Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Så när du i vanliga fall ska skriva en metod i en klass så gör du såhär
- using windowUtils;
- public class OfficeManager2020
- {
- public Employee vd;
- public Employee[] office;
- public void Setup()
- {
- windowUtils.output("Welcome to the setup for Office Manager 2020!\nPlease enter the name of your VD: ");
- string vdName = windowUtils.input();
- windowUtils.output("\nPlease enter age: ");
- int vdAge = int.parse(windowUtils.input());
- vd = new Employee(vdName, vdAge, "VD");
- }
- public void newEmployee()
- {
- windowUtils.output("Please enter name:");
- string n = windowUtils.input();
- windowUtils.output("\nPlease enter age:");
- int a = int.parse(windowUtils.input());
- windowUtils.output("\nPlease enter rank:");
- string r = windowUtils.input();
- office[office.length()] = new Employee(n, a, r);
- }
- public string employeeInfo(string employeeName)
- {
- string output = "";
- int employeenumber = 0;
- foreach(Employee e in office)
- {
- }
- }
- }
- public class Employee
- {
- public int age;
- public string name;
- public string rank;
- public Employee() // En constructor metod som används för att skapa ett nytt objekt
- { // (en instans) med typen som klassen representerar
- age = 0;
- name = "Unknown";
- rank = "unknown"
- }
- public Employee(string n, int a, string r) // En till constructor metod som används på samma sätt
- { // men låter en sätta objektets property variabler.
- age = a;
- name = n;
- rank = r;
- }
- public string getName() // En funktion i klassen som i det här fallet returnerar property namn
- {
- return name;
- }
- public int getAge()
- {
- return age;
- }
- public string getRank()
- {
- return rank;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement