diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json new file mode 100644 index 0000000..f8b4888 --- /dev/null +++ b/.vs/ProjectSettings.json @@ -0,0 +1,3 @@ +{ + "CurrentProjectSetting": null +} \ No newline at end of file diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 0000000..6b61141 --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,6 @@ +{ + "ExpandedNodes": [ + "" + ], + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vs/coding-evaluation/FileContentIndex/43f86783-1b40-4f8d-9447-f553af3d146a.vsidx b/.vs/coding-evaluation/FileContentIndex/43f86783-1b40-4f8d-9447-f553af3d146a.vsidx new file mode 100644 index 0000000..0f4ef2d Binary files /dev/null and b/.vs/coding-evaluation/FileContentIndex/43f86783-1b40-4f8d-9447-f553af3d146a.vsidx differ diff --git a/.vs/coding-evaluation/FileContentIndex/read.lock b/.vs/coding-evaluation/FileContentIndex/read.lock new file mode 100644 index 0000000..e69de29 diff --git a/.vs/coding-evaluation/v17/.wsuo b/.vs/coding-evaluation/v17/.wsuo new file mode 100644 index 0000000..d108b8b Binary files /dev/null and b/.vs/coding-evaluation/v17/.wsuo differ diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 0000000..089dbcb Binary files /dev/null and b/.vs/slnx.sqlite differ diff --git a/dotnet/MyOrganization/Organization.cs b/dotnet/MyOrganization/Organization.cs index 7480481..0383a97 100644 --- a/dotnet/MyOrganization/Organization.cs +++ b/dotnet/MyOrganization/Organization.cs @@ -17,6 +17,9 @@ public Organization() protected abstract Position CreateOrganization(); + // This is to generate identifier for the Employees + int identifier = 1; + /** * hire the given person as an employee in the position that has that title * @@ -26,7 +29,22 @@ public Organization() */ public Position? Hire(Name person, string title) { - //your code here + Employee employee = new Employee(identifier++, person); + return CheckDirectReportPositions(root, employee, title); + } + + private Position? CheckDirectReportPositions(Position pos, Employee employee, string title) + { + if (pos.GetTitle() == title) + { + pos.SetEmployee(employee); + return pos; + } + + foreach (Position p in pos.GetDirectReports()) + { + CheckDirectReportPositions(p, employee, title); + } return null; } @@ -45,4 +63,4 @@ private string PrintOrganization(Position pos, string prefix) return sb.ToString(); } } -} +} \ No newline at end of file diff --git a/java/.gitignore b/java/.gitignore deleted file mode 100644 index 8399968..0000000 --- a/java/.gitignore +++ /dev/null @@ -1 +0,0 @@ -**/*.class \ No newline at end of file diff --git a/java/README.md b/java/README.md deleted file mode 100644 index 469e379..0000000 --- a/java/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Coding evaluation -Your goal is to make this project functional by completing the `hire()` method in the `Organization` class. You are free to change existing code or add additonal code, with the exception of `MyOrganization.java`. This file must not be changed. - -## Running the project -This project should be run on a Java 11 or later JVM. It can be compiled and run in your favorite IDE or by using the command line instructions below. - -Compile the project by running: - - javac com/aa/act/interview/org/*.java - -The `MyOrganization` class has a `main()` method, so the project can be run with: - - java com.aa.act.interview.org.MyOrganization - diff --git a/java/com/aa/act/interview/org/Employee.java b/java/com/aa/act/interview/org/Employee.java deleted file mode 100644 index 0e40b90..0000000 --- a/java/com/aa/act/interview/org/Employee.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.aa.act.interview.org; - -public class Employee { - - private int identifier; - private Name name; - - public Employee(int identifier, Name name) { - if(name == null) - throw new IllegalArgumentException("name cannot be null"); - this.identifier = identifier; - this.name = name; - } - - public int getIdentifier() { - return identifier; - } - - public Name getName() { - return name; - } - - @Override - public String toString() { - return name.toString() + ": " + identifier; - } -} diff --git a/java/com/aa/act/interview/org/MyOrganization.java b/java/com/aa/act/interview/org/MyOrganization.java deleted file mode 100644 index a6048da..0000000 --- a/java/com/aa/act/interview/org/MyOrganization.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.aa.act.interview.org; - -public class MyOrganization extends Organization { - - @Override - protected Position createOrganization() { - Position ceo = new Position("CEO"); - Position pres = new Position("President"); - ceo.addDirectReport(pres); - Position vpm = new Position("VP Marketing"); - pres.addDirectReport(vpm); - Position vps = new Position("VP Sales"); - pres.addDirectReport(vps); - Position vpf = new Position("VP Finance"); - pres.addDirectReport(vpf); - Position coo = new Position("COO"); - pres.addDirectReport(coo); - Position cio = new Position("CIO"); - ceo.addDirectReport(cio); - Position vpt = new Position("VP Technology"); - cio.addDirectReport(vpt); - Position vpi = new Position("VP Infrastructure"); - cio.addDirectReport(vpi); - Position dea = new Position("Director Enterprise Architecture"); - vpt.addDirectReport(dea); - Position dct = new Position("Director Customer Technology"); - vpt.addDirectReport(dct); - Position s = new Position("Salesperson"); - vps.addDirectReport(s); - - return ceo; - } - - public static final void main(String... args) { - MyOrganization myOrg = new MyOrganization(); - myOrg.hire(new Name("Bob", "Smith"), "CEO"); - myOrg.hire(new Name("Zaphod", "Beeblebrox"), "President"); - myOrg.hire(new Name("Gandalf", "Gray"), "Director Enterprise Architecture"); - myOrg.hire(new Name("Bill", "Lumbergh"), "Director Customer Technology"); - myOrg.hire(new Name("Ford", "Prefect"), "VP Marketing"); - myOrg.hire(new Name("Jane", "Seller"), "VP Sales"); - myOrg.hire(new Name("Bean", "Counter"), "VP Finance"); - myOrg.hire(new Name("Victoria", "Sinclair"), "CIO"); - myOrg.hire(new Name("Head", "Geek"), "VP Technology"); - myOrg.hire(new Name("Steve", "Dent"), "VP Infrastructure"); - myOrg.hire(new Name("Slick", "Willie"), "Salesperson"); - System.out.println(myOrg); - } -} diff --git a/java/com/aa/act/interview/org/Name.java b/java/com/aa/act/interview/org/Name.java deleted file mode 100644 index edb78b1..0000000 --- a/java/com/aa/act/interview/org/Name.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.aa.act.interview.org; - -public class Name { - - private String first; - private String last; - - public Name(String first, String last) { - if(first == null) - throw new IllegalArgumentException("first name cannot be null"); - if(last == null) - throw new IllegalArgumentException("last name cannot be null"); - this.first = first; - this.last = last; - } - - public String getFirst() { - return first; - } - - public String getLast() { - return last; - } - - @Override - public String toString() { - return first + " " + last; - } -} diff --git a/java/com/aa/act/interview/org/Organization.java b/java/com/aa/act/interview/org/Organization.java deleted file mode 100644 index e1c8ed1..0000000 --- a/java/com/aa/act/interview/org/Organization.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.aa.act.interview.org; - -import java.util.Optional; - -public abstract class Organization { - - private Position root; - - public Organization() { - root = createOrganization(); - } - - protected abstract Position createOrganization(); - - /** - * hire the given person as an employee in the position that has that title - * - * @param person - * @param title - * @return the newly filled position or empty if no position has that title - */ - public Optional hire(Name person, String title) { - //your code here - return Optional.empty(); - } - - @Override - public String toString() { - return printOrganization(root, ""); - } - - private String printOrganization(Position pos, String prefix) { - StringBuffer sb = new StringBuffer(prefix + "+-" + pos.toString() + "\n"); - for(Position p : pos.getDirectReports()) { - sb.append(printOrganization(p, prefix + " ")); - } - return sb.toString(); - } -} diff --git a/java/com/aa/act/interview/org/Position.java b/java/com/aa/act/interview/org/Position.java deleted file mode 100644 index f2757ba..0000000 --- a/java/com/aa/act/interview/org/Position.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.aa.act.interview.org; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; - -public class Position { - - private String title; - private Optional employee; - private Set directReports; - - public Position(String title) { - this.title = title; - employee = Optional.empty(); - directReports = new HashSet(); - } - - public Position(String title, Employee employee) { - this(title); - if(employee != null) - setEmployee(Optional.of(employee)); - } - - public String getTitle() { - return title; - } - - public void setEmployee(Optional employee) { - this.employee = employee; - } - - public Optional getEmployee() { - return employee; - } - - public boolean isFilled() { - return employee.isPresent(); - } - - public boolean addDirectReport(Position position) { - if(position == null) - throw new IllegalArgumentException("position cannot be null"); - return directReports.add(position); - } - - public boolean removePosition(Position position) { - return directReports.remove(position); - } - - public Collection getDirectReports() { - return Collections.unmodifiableCollection(directReports); - } - - @Override - public String toString() { - return title + employee.map(e -> ": " + e.toString()).orElse(""); - } -} diff --git a/javascript-es5/Employee.js b/javascript-es5/Employee.js deleted file mode 100644 index 592bfa3..0000000 --- a/javascript-es5/Employee.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = function (identifier, name) { - if (!name) { - throw new Error('name cannot be null'); - } - return { - getIdentifier: function () { return identifier; }, - getName: function () { return name; }, - toString: function () { - return `${name.toString()}: ${identifier}`; - }, - }; -}; diff --git a/javascript-es5/MyOrganization.js b/javascript-es5/MyOrganization.js deleted file mode 100644 index 5fda969..0000000 --- a/javascript-es5/MyOrganization.js +++ /dev/null @@ -1,43 +0,0 @@ -const Name = require('./Name.js'); -const Organization = require('./Organization.js'); -const Position = require('./Position.js'); - -const ceo = Position('CEO'); -const pres = Position('President'); -ceo.addDirectReport(pres); -const vpm = Position('VP Marketing'); -pres.addDirectReport(vpm); -const vps = Position('VP Sales'); -pres.addDirectReport(vps); -const vpf = Position('VP Finance'); -pres.addDirectReport(vpf); -const coo = Position('COO'); -pres.addDirectReport(coo); -const cio = Position('CIO'); -ceo.addDirectReport(cio); -const vpt = Position('VP Technology'); -cio.addDirectReport(vpt); -const vpi = Position('VP Infrastructure'); -cio.addDirectReport(vpi); -const dea = Position('Director Enterprise Architecture'); -vpt.addDirectReport(dea); -const dct = Position('Director Customer Technology'); -vpt.addDirectReport(dct); -const s = Position('Salesperson'); -vps.addDirectReport(s); - -const myOrg = Organization(ceo); - -myOrg.hire(Name('Bob', 'Smith'), 'CEO'); -myOrg.hire(Name('Zaphod', 'Beeblebrox'), 'President'); -myOrg.hire(Name('Gandalf', 'Gray'), 'Director Enterprise Architecture'); -myOrg.hire(Name('Bill', 'Lumbergh'), 'Director Customer Technology'); -myOrg.hire(Name('Ford', 'Prefect'), 'VP Marketing'); -myOrg.hire(Name('Jane', 'Seller'), 'VP Sales'); -myOrg.hire(Name('Bean', 'Counter'), 'VP Finance'); -myOrg.hire(Name('Victoria', 'Sinclair'), 'CIO'); -myOrg.hire(Name('Head', 'Geek'), 'VP Technology'); -myOrg.hire(Name('Steve', 'Dent'), 'VP Infrastructure'); -myOrg.hire(Name('Slick', 'Willie'), 'Salesperson'); - -console.log(myOrg.toString()); diff --git a/javascript-es5/Name.js b/javascript-es5/Name.js deleted file mode 100644 index 380d01b..0000000 --- a/javascript-es5/Name.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = function (first, last) { - if (!first) { - throw new Error('first name cannot be null'); - } - if (!last) { - throw new Error('last name cannot be null'); - } - return { - getFirst: function () { return first; }, - getLast: function () { return last; }, - toString: function () { return `${first} ${last}`; }, - }; -}; diff --git a/javascript-es5/Organization.js b/javascript-es5/Organization.js deleted file mode 100644 index b73b1e2..0000000 --- a/javascript-es5/Organization.js +++ /dev/null @@ -1,22 +0,0 @@ -module.exports = function (root) { - return { - getRoot: function () { return root; }, - - printOrganization: function (position, prefix) { - let str = `${prefix}+-${position.toString()}\n`; - for (const p of position.getDirectReports()) { - str = str.concat(this.printOrganization(p, `${prefix} `)); - } - return str; - }, - // Hire the given person as an employee in the position that has that title - // Return the newly filled position or undefined if no position has that title - hire: function (person, title) { - // your code here - }, - - toString: function () { - return this.printOrganization(root, ''); - } - }; -}; diff --git a/javascript-es5/Position.js b/javascript-es5/Position.js deleted file mode 100644 index e9f740c..0000000 --- a/javascript-es5/Position.js +++ /dev/null @@ -1,37 +0,0 @@ -module.exports = function (title, employee) { - const directReports = new Set(); - - return { - isFilled: function () { - return !!employee; - }, - - getTitle: function () { return title; }, - - setEmployee: function (emp) { employee = emp; }, - - getEmployee: function () { return employee; }, - - addDirectReport: function (position) { - if (!position) { - throw new Error('position cannot be null'); - } - directReports.add(position); - }, - - removePosition: function (position) { - return directReports.delete(position); - }, - - getDirectReports: function () { - const reports = []; - directReports.forEach(function (position) { reports.push(position); }); - return reports; - }, - - toString: function () { - const emp = employee ? `: ${employee.toString()}` : ''; - return `${title}${emp}`; - } - }; -}; diff --git a/javascript-es5/README.md b/javascript-es5/README.md deleted file mode 100644 index 393ec78..0000000 --- a/javascript-es5/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Coding evaluation -Your goal is to make this project functional by completing the `hire()` function in the `Organization.js` file. You are free to change existing code or add additonal code, with the exception of `MyOrganization.js`. This file must not be changed. - -## Running the project -This project should be run on Node v14 or later. The project can be run in your favorite IDE or by running `npm start`. \ No newline at end of file diff --git a/javascript-es5/package.json b/javascript-es5/package.json deleted file mode 100644 index e5656cd..0000000 --- a/javascript-es5/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "codingeval-es5", - "version": "1.0.0", - "private": true, - "description": "Coding evaluation for interviews - ES5 edition", - "main": "MyOrganization.js", - "scripts": { - "start": "node ./MyOrganization.js" - }, - "author": "American Airlines" -} diff --git a/javascript-es6/Employee.js b/javascript-es6/Employee.js deleted file mode 100644 index 2c596ce..0000000 --- a/javascript-es6/Employee.js +++ /dev/null @@ -1,12 +0,0 @@ -class Employee { - constructor(identifier, name) { - if (!name) { - throw new Error('name cannot be null'); - } - this.getIdentifier = () => identifier; - this.getName = () => name - this.toString = () => `${name.toString()}: ${identifier}`; - } -} - -export default Employee; diff --git a/javascript-es6/MyOrganization.js b/javascript-es6/MyOrganization.js deleted file mode 100644 index 87ccfd1..0000000 --- a/javascript-es6/MyOrganization.js +++ /dev/null @@ -1,43 +0,0 @@ -import Name from './Name.js'; -import Organization from './Organization.js'; -import Position from './Position.js'; - -const ceo = new Position('CEO'); -const pres = new Position('President'); -ceo.addDirectReport(pres); -const vpm = new Position('VP Marketing'); -pres.addDirectReport(vpm); -const vps = new Position('VP Sales'); -pres.addDirectReport(vps); -const vpf = new Position('VP Finance'); -pres.addDirectReport(vpf); -const coo = new Position('COO'); -pres.addDirectReport(coo); -const cio = new Position('CIO'); -ceo.addDirectReport(cio); -const vpt = new Position('VP Technology'); -cio.addDirectReport(vpt); -const vpi = new Position('VP Infrastructure'); -cio.addDirectReport(vpi); -const dea = new Position('Director Enterprise Architecture'); -vpt.addDirectReport(dea); -const dct = new Position('Director Customer Technology'); -vpt.addDirectReport(dct); -const s = new Position('Salesperson'); -vps.addDirectReport(s); - -const myOrg = new Organization(ceo); - -myOrg.hire(new Name('Bob', 'Smith'), 'CEO'); -myOrg.hire(new Name('Zaphod', 'Beeblebrox'), 'President'); -myOrg.hire(new Name('Gandalf', 'Gray'), 'Director Enterprise Architecture'); -myOrg.hire(new Name('Bill', 'Lumbergh'), 'Director Customer Technology'); -myOrg.hire(new Name('Ford', 'Prefect'), 'VP Marketing'); -myOrg.hire(new Name('Jane', 'Seller'), 'VP Sales'); -myOrg.hire(new Name('Bean', 'Counter'), 'VP Finance'); -myOrg.hire(new Name('Victoria', 'Sinclair'), 'CIO'); -myOrg.hire(new Name('Head', 'Geek'), 'VP Technology'); -myOrg.hire(new Name('Steve', 'Dent'), 'VP Infrastructure'); -myOrg.hire(new Name('Slick', 'Willie'), 'Salesperson'); - -console.log(myOrg.toString()); diff --git a/javascript-es6/Name.js b/javascript-es6/Name.js deleted file mode 100644 index ca676f4..0000000 --- a/javascript-es6/Name.js +++ /dev/null @@ -1,15 +0,0 @@ -class Name { - constructor(first, last) { - if (!first) { - throw new Error('first name cannot be null'); - } - if (!last) { - throw new Error('last name cannot be null'); - } - this.getFirst = () => first; - this.getLast = () => last; - this.toString = () => `${first} ${last}`; - } -} - -export default Name; diff --git a/javascript-es6/Organization.js b/javascript-es6/Organization.js deleted file mode 100644 index e49bc28..0000000 --- a/javascript-es6/Organization.js +++ /dev/null @@ -1,21 +0,0 @@ -class Organization { - constructor(root) { - this.printOrganization = (position, prefix) => { - let str = `${prefix}+-${position.toString()}\n`; - for (const p of position.getDirectReports()) { - str = str.concat(this.printOrganization(p, `${prefix} `)); - } - return str; - }; - - // Hire the given person as an employee in the position that has that title - // Return the newly filled position or undefined if no position has that title - this.hire = (person, title) => { - // your code here - }; - - this.toString = () => this.printOrganization(root, ''); - }; -} - -export default Organization; diff --git a/javascript-es6/Position.js b/javascript-es6/Position.js deleted file mode 100644 index 12776d9..0000000 --- a/javascript-es6/Position.js +++ /dev/null @@ -1,35 +0,0 @@ -class Position { - constructor(title, employee) { - const directReports = new Set(); - - this.isFilled = () => !!employee; - - this.getTitle = () => title; - - this.setEmployee = (emp) => employee = emp; - - this.getEmployee = () => employee; - - this.addDirectReport = (position) => { - if (!position) { - throw new Error('position cannot be null'); - } - directReports.add(position); - }; - - this.removePosition = (position) => directReports.delete(position); - - this.getDirectReports = () => { - const reports = []; - directReports.forEach(position => reports.push(position)); - return reports; - }; - - this.toString = () => { - const emp = employee ? `: ${employee.toString()}` : ''; - return `${title}${emp.toString()}`; - }; - } -} - -export default Position; diff --git a/javascript-es6/README.md b/javascript-es6/README.md deleted file mode 100644 index 393ec78..0000000 --- a/javascript-es6/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Coding evaluation -Your goal is to make this project functional by completing the `hire()` function in the `Organization.js` file. You are free to change existing code or add additonal code, with the exception of `MyOrganization.js`. This file must not be changed. - -## Running the project -This project should be run on Node v14 or later. The project can be run in your favorite IDE or by running `npm start`. \ No newline at end of file diff --git a/javascript-es6/package.json b/javascript-es6/package.json deleted file mode 100644 index 13794ff..0000000 --- a/javascript-es6/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "codingeval-es6", - "version": "1.0.0", - "private": true, - "description": "Coding evaluation for interviews - ES6 edition", - "main": "MyOrganization.js", - "type": "module", - "scripts": { - "start": "node ./MyOrganization.js" - }, - "author": "American Airlines" -} diff --git a/typescript/.gitignore b/typescript/.gitignore deleted file mode 100644 index b512c09..0000000 --- a/typescript/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/typescript/Employee.ts b/typescript/Employee.ts deleted file mode 100644 index 5d6c117..0000000 --- a/typescript/Employee.ts +++ /dev/null @@ -1,9 +0,0 @@ -import Name from './Name'; - -class Employee { - constructor(private readonly identifier: number, private readonly name: Name) { } - - toString = () => `${this.name.toString()}: ${this.identifier}`; -} - -export default Employee; diff --git a/typescript/MyOrganization.ts b/typescript/MyOrganization.ts deleted file mode 100644 index 8a6180a..0000000 --- a/typescript/MyOrganization.ts +++ /dev/null @@ -1,46 +0,0 @@ -import Name from './Name'; -import Organization from './Organization'; -import Position from './Position'; - -class MyOrganization extends Organization { - createOrganization(): Position { - const ceo = new Position('CEO'); - const pres = new Position('President'); - ceo.addDirectReport(pres); - const vpm = new Position('VP Marketing'); - pres.addDirectReport(vpm); - const vps = new Position('VP Sales'); - pres.addDirectReport(vps); - const vpf = new Position('VP Finance'); - pres.addDirectReport(vpf); - const coo = new Position('COO'); - pres.addDirectReport(coo); - const cio = new Position('CIO'); - ceo.addDirectReport(cio); - const vpt = new Position('VP Technology'); - cio.addDirectReport(vpt); - const vpi = new Position('VP Infrastructure'); - cio.addDirectReport(vpi); - const dea = new Position('Director Enterprise Architecture'); - vpt.addDirectReport(dea); - const dct = new Position('Director Customer Technology'); - vpt.addDirectReport(dct); - const s = new Position('Salesperson'); - vps.addDirectReport(s); - return ceo; - } -} - -const myOrg = new MyOrganization(); -myOrg.hire(new Name('Bob', 'Smith'), 'CEO'); -myOrg.hire(new Name('Zaphod', 'Beeblebrox'), 'President'); -myOrg.hire(new Name('Gandalf', 'Gray'), 'Director Enterprise Architecture'); -myOrg.hire(new Name('Bill', 'Lumbergh'), 'Director Customer Technology'); -myOrg.hire(new Name('Ford', 'Prefect'), 'VP Marketing'); -myOrg.hire(new Name('Jane', 'Seller'), 'VP Sales'); -myOrg.hire(new Name('Bean', 'Counter'), 'VP Finance'); -myOrg.hire(new Name('Victoria', 'Sinclair'), 'CIO'); -myOrg.hire(new Name('Head', 'Geek'), 'VP Technology'); -myOrg.hire(new Name('Steve', 'Dent'), 'VP Infrastructure'); -myOrg.hire(new Name('Slick', 'Willie'), 'Salesperson'); -console.log(myOrg.toString()); diff --git a/typescript/Name.ts b/typescript/Name.ts deleted file mode 100644 index 760a1b3..0000000 --- a/typescript/Name.ts +++ /dev/null @@ -1,7 +0,0 @@ -class Name { - constructor(private readonly first: string, private readonly last: string) { } - - toString = () => `${this.first} ${this.last}`; -} - -export default Name; diff --git a/typescript/Organization.ts b/typescript/Organization.ts deleted file mode 100644 index 59baeca..0000000 --- a/typescript/Organization.ts +++ /dev/null @@ -1,31 +0,0 @@ -import Position from './Position'; -import Name from './Name'; - -abstract class Organization { - private root: Position; - - constructor() { - this.root = this.createOrganization(); - } - - protected abstract createOrganization(): Position; - - printOrganization = (position: Position, prefix: string): string => { - let str = `${prefix}+-${position}\n`; - for (const p of position.getDirectReports()) { - str = str.concat(this.printOrganization(p, `${prefix} `)); - } - return str; - }; - - // Hire the given person as an employee in the position that has that title - // Return the newly filled position or undefined if no position has that title - hire(person: Name, title: string): Position | undefined { - // your code here - return undefined - } - - toString = () => this.printOrganization(this.root, ''); -} - -export default Organization; diff --git a/typescript/Position.ts b/typescript/Position.ts deleted file mode 100644 index aad9580..0000000 --- a/typescript/Position.ts +++ /dev/null @@ -1,37 +0,0 @@ -import Employee from './Employee'; - -class Position { - private directReports: Set = new Set(); - - constructor(private title: string, private employee?: Employee) { } - - isFilled = (): boolean => !!this.employee; - - getTitle = (): string => this.title; - - setEmployee = (employee: Employee): void => { this.employee = employee; }; - - getEmployee = (): Employee | undefined => this.employee; - - addDirectReport = (position: Position): void => { - if (!position) { - throw new Error('position cannot be null'); - } - this.directReports.add(position); - }; - - removePosition = (position): boolean => this.directReports.delete(position); - - getDirectReports = (): Position[] => { - const reports: Position[] = []; - this.directReports.forEach(position => reports.push(position)); - return reports; - }; - - toString = () => { - const employee = this.employee ? `: ${this.employee}` : ''; - return `${this.title}${employee}`; - }; -} - -export default Position; diff --git a/typescript/README.md b/typescript/README.md deleted file mode 100644 index 35db165..0000000 --- a/typescript/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Coding evaluation -Your goal is to make this project functional by completing the `hire()` function in the `Organization.ts` file. You are free to change existing code or add additonal code, with the exception of `MyOrganization.ts`. This file must not be changed. - -## Running the project -This project should be run on Node v14 or later using the `ts-node` TypeScript engine. `ts-node` can be installed by running `npm install`. The project can then be run in your favorite IDE or by running `npm start`. diff --git a/typescript/package-lock.json b/typescript/package-lock.json deleted file mode 100644 index 4b8501d..0000000 --- a/typescript/package-lock.json +++ /dev/null @@ -1,361 +0,0 @@ -{ - "name": "codingeval-ts", - "version": "1.0.0", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "name": "codingeval-ts", - "version": "1.0.0", - "devDependencies": { - "ts-node": "^10.8.0", - "typescript": "^4.7.2" - } - }, - "node_modules/@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/trace-mapping": "0.3.9" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.0.7", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@jridgewell/resolve-uri/-/resolve-uri-3.0.7.tgz", - "integrity": "sha512-8cXDaBBHOr2pQ7j77Y6Vp5VDT2sIqWyWQ56TjEq4ih/a4iST3dItRe8Q9fp0rrIl9DoKhWQtUQz/YpOxLkXbNA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.13", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.13.tgz", - "integrity": "sha512-GryiOJmNcWbovBxTfZSF71V/mXbgcV3MewDe3kIMCLyIh5e7SKAeUZs+rMnJ8jkMolZ/4/VsdBmMrw3l+VdZ3w==", - "dev": true, - "license": "MIT" - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, - "node_modules/@tsconfig/node10": { - "version": "1.0.8", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@tsconfig/node10/-/node10-1.0.8.tgz", - "integrity": "sha1-weToDW+WT77LM1nEO9SLQPfK2tk=", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node12": { - "version": "1.0.9", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@tsconfig/node12/-/node12-1.0.9.tgz", - "integrity": "sha1-YsH23uLr2a6tgNw6+laBDljhoEw=", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node14": { - "version": "1.0.1", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@tsconfig/node14/-/node14-1.0.1.tgz", - "integrity": "sha1-lfLRZ/+5uNIGiwsjUwL6/U33EfI=", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node16": { - "version": "1.0.2", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@tsconfig/node16/-/node16-1.0.2.tgz", - "integrity": "sha1-Qjx3h30Fadsg4fyAiFrEEYMUAQ4=", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/node": { - "version": "17.0.35", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@types/node/-/node-17.0.35.tgz", - "integrity": "sha512-vu1SrqBjbbZ3J6vwY17jBs8Sr/BKA+/a/WtjRG+whKg1iuLFOosq872EXS0eXWILdO36DHQQeku/ZcL6hz2fpg==", - "dev": true, - "license": "MIT", - "peer": true - }, - "node_modules/acorn": { - "version": "8.4.1", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/acorn/-/acorn-8.4.1.tgz", - "integrity": "sha1-VsNiUfx8q8cJatwY8Fr+gUMhoow=", - "dev": true, - "license": "MIT", - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-walk": { - "version": "8.1.1", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/acorn-walk/-/acorn-walk-8.1.1.tgz", - "integrity": "sha1-Pdq3+E5KfiMT9sQUxbfayF9OPrw=", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/arg": { - "version": "4.1.3", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/arg/-/arg-4.1.3.tgz", - "integrity": "sha1-Jp/HrVuOQstjyJbVZmAXJhwUQIk=", - "dev": true, - "license": "MIT" - }, - "node_modules/create-require": { - "version": "1.1.1", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha1-wdfo8eX2z8n/ZfnNNS03NIdWwzM=", - "dev": true, - "license": "MIT" - }, - "node_modules/diff": { - "version": "4.0.2", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/diff/-/diff-4.0.2.tgz", - "integrity": "sha1-YPOuy4nV+uUgwRqhnvwruYKq3n0=", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.3.1" - } - }, - "node_modules/make-error": { - "version": "1.3.6", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha1-LrLjfqm2fEiR9oShOUeZr0hM96I=", - "dev": true, - "license": "ISC" - }, - "node_modules/ts-node": { - "version": "10.8.0", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/ts-node/-/ts-node-10.8.0.tgz", - "integrity": "sha512-/fNd5Qh+zTt8Vt1KbYZjRHCE9sI5i7nqfD/dzBBRDeVXZXS6kToW6R7tTU6Nd4XavFs0mAVCg29Q//ML7WsZYA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - }, - "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" - }, - "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } - } - }, - "node_modules/typescript": { - "version": "4.7.2", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/typescript/-/typescript-4.7.2.tgz", - "integrity": "sha512-Mamb1iX2FDUpcTRzltPxgWMKy3fhg0TN378ylbktPGPK/99KbDtMQ4W1hwgsbPAsG3a0xKa1vmw4VKZQbkvz5A==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true, - "license": "MIT" - }, - "node_modules/yn": { - "version": "3.1.1", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/yn/-/yn-3.1.1.tgz", - "integrity": "sha1-HodAGgnXZ8HV6rJqbkwYUYLS61A=", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - } - }, - "dependencies": { - "@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "requires": { - "@jridgewell/trace-mapping": "0.3.9" - } - }, - "@jridgewell/resolve-uri": { - "version": "3.0.7", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@jridgewell/resolve-uri/-/resolve-uri-3.0.7.tgz", - "integrity": "sha512-8cXDaBBHOr2pQ7j77Y6Vp5VDT2sIqWyWQ56TjEq4ih/a4iST3dItRe8Q9fp0rrIl9DoKhWQtUQz/YpOxLkXbNA==", - "dev": true - }, - "@jridgewell/sourcemap-codec": { - "version": "1.4.13", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.13.tgz", - "integrity": "sha512-GryiOJmNcWbovBxTfZSF71V/mXbgcV3MewDe3kIMCLyIh5e7SKAeUZs+rMnJ8jkMolZ/4/VsdBmMrw3l+VdZ3w==", - "dev": true - }, - "@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, - "requires": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, - "@tsconfig/node10": { - "version": "1.0.8", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@tsconfig/node10/-/node10-1.0.8.tgz", - "integrity": "sha1-weToDW+WT77LM1nEO9SLQPfK2tk=", - "dev": true - }, - "@tsconfig/node12": { - "version": "1.0.9", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@tsconfig/node12/-/node12-1.0.9.tgz", - "integrity": "sha1-YsH23uLr2a6tgNw6+laBDljhoEw=", - "dev": true - }, - "@tsconfig/node14": { - "version": "1.0.1", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@tsconfig/node14/-/node14-1.0.1.tgz", - "integrity": "sha1-lfLRZ/+5uNIGiwsjUwL6/U33EfI=", - "dev": true - }, - "@tsconfig/node16": { - "version": "1.0.2", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@tsconfig/node16/-/node16-1.0.2.tgz", - "integrity": "sha1-Qjx3h30Fadsg4fyAiFrEEYMUAQ4=", - "dev": true - }, - "@types/node": { - "version": "17.0.35", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/@types/node/-/node-17.0.35.tgz", - "integrity": "sha512-vu1SrqBjbbZ3J6vwY17jBs8Sr/BKA+/a/WtjRG+whKg1iuLFOosq872EXS0eXWILdO36DHQQeku/ZcL6hz2fpg==", - "dev": true, - "peer": true - }, - "acorn": { - "version": "8.4.1", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/acorn/-/acorn-8.4.1.tgz", - "integrity": "sha1-VsNiUfx8q8cJatwY8Fr+gUMhoow=", - "dev": true - }, - "acorn-walk": { - "version": "8.1.1", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/acorn-walk/-/acorn-walk-8.1.1.tgz", - "integrity": "sha1-Pdq3+E5KfiMT9sQUxbfayF9OPrw=", - "dev": true - }, - "arg": { - "version": "4.1.3", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/arg/-/arg-4.1.3.tgz", - "integrity": "sha1-Jp/HrVuOQstjyJbVZmAXJhwUQIk=", - "dev": true - }, - "create-require": { - "version": "1.1.1", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha1-wdfo8eX2z8n/ZfnNNS03NIdWwzM=", - "dev": true - }, - "diff": { - "version": "4.0.2", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/diff/-/diff-4.0.2.tgz", - "integrity": "sha1-YPOuy4nV+uUgwRqhnvwruYKq3n0=", - "dev": true - }, - "make-error": { - "version": "1.3.6", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha1-LrLjfqm2fEiR9oShOUeZr0hM96I=", - "dev": true - }, - "ts-node": { - "version": "10.8.0", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/ts-node/-/ts-node-10.8.0.tgz", - "integrity": "sha512-/fNd5Qh+zTt8Vt1KbYZjRHCE9sI5i7nqfD/dzBBRDeVXZXS6kToW6R7tTU6Nd4XavFs0mAVCg29Q//ML7WsZYA==", - "dev": true, - "requires": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - } - }, - "typescript": { - "version": "4.7.2", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/typescript/-/typescript-4.7.2.tgz", - "integrity": "sha512-Mamb1iX2FDUpcTRzltPxgWMKy3fhg0TN378ylbktPGPK/99KbDtMQ4W1hwgsbPAsG3a0xKa1vmw4VKZQbkvz5A==", - "dev": true - }, - "v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true - }, - "yn": { - "version": "3.1.1", - "resolved": "https://packages.aa.com/artifactory/api/npm/npm-public/yn/-/yn-3.1.1.tgz", - "integrity": "sha1-HodAGgnXZ8HV6rJqbkwYUYLS61A=", - "dev": true - } - } -} diff --git a/typescript/package.json b/typescript/package.json deleted file mode 100644 index 74184ef..0000000 --- a/typescript/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "codingeval-ts", - "version": "1.0.0", - "private": true, - "description": "Coding evaluation for interviews - Typescript edition", - "main": "MyOrganization.ts", - "scripts": { - "start": "ts-node ./MyOrganization.ts" - }, - "author": "American Airlines", - "devDependencies": { - "ts-node": "^10.8.0", - "typescript": "^4.7.2" - } -} diff --git a/typescript/tsconfig.json b/typescript/tsconfig.json deleted file mode 100644 index 01e267d..0000000 --- a/typescript/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true, - "lib": [ "ES2015", "dom" ] - } -} \ No newline at end of file