Skip to content

Commit

Permalink
Merge pull request #7 from friedalexuni/main
Browse files Browse the repository at this point in the history
Added homework B02 skeleton (no tests included)
  • Loading branch information
dirkriehle authored Oct 22, 2024
2 parents 1be00d7 + be58930 commit 2b4aa56
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/adap-b01/names/Name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class Name {
throw new Error("needs implementation");
}

// Returns human-readable representation of Name instance
public asNameString(delimiter: string = this.delimiter): string {
throw new Error("needs implementation");
}
Expand Down
20 changes: 20 additions & 0 deletions src/adap-b02/names/Name.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export const DEFAULT_DELIMITER: string = '.';
export const ESCAPE_CHARACTER = '\\';

export interface Name {

// Returns human-readable representation of Name instance
asNameString(delimiter?: string): string;

isEmpty(): boolean;

getNoComponents(): number;

getComponent(i: number): string;
setComponent(i: number, c: string): void;

insert(i: number, c: string): void;
append(c: string): void;
remove(i: number): void;

}
48 changes: 48 additions & 0 deletions src/adap-b02/names/StringArrayName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Name, DEFAULT_DELIMITER, ESCAPE_CHARACTER } from "./Name";

export class StringArrayName implements Name {

protected components: string[] = [];
protected delimiter: string = DEFAULT_DELIMITER;

constructor(other: string[], delimiter?: string) {
throw new Error("needs implementation");
}

public asNameString(delimiter: string = this.delimiter): string {
throw new Error("needs implementation");
}

public isEmpty(): boolean {
throw new Error("needs implementation");
}

public getNoComponents(): number {
throw new Error("needs implementation");
}

public getComponent(i: number): string {
throw new Error("needs implementation");
}

public setComponent(i: number, c: string): void {
throw new Error("needs implementation");
}

public insert(i: number, c: string): void {
throw new Error("needs implementation");
}

public append(c: string): void {
throw new Error("needs implementation");
}

public remove(i: number): void {
throw new Error("needs implementation");
}

public concat(other: Name): void {
throw new Error("needs implementation");
}

}
50 changes: 50 additions & 0 deletions src/adap-b02/names/StringName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Name, DEFAULT_DELIMITER, ESCAPE_CHARACTER } from "./Name";

export class StringName implements Name {

protected delimiter: string = DEFAULT_DELIMITER;

protected name: string = "";
protected length: number = 0; // Number of components in Name instance

constructor(other: string, delimiter?: string) {
throw new Error("needs implementation");
}

public asNameString(delimiter: string = this.delimiter): string {
throw new Error("needs implementation");
}

public isEmpty(): boolean {
throw new Error("needs implementation");
}

public getNoComponents(): number {
throw new Error("needs implementation");
}

public getComponent(x: number): string {
throw new Error("needs implementation");
}

public setComponent(n: number, c: string): void {
throw new Error("needs implementation");
}

public insert(n: number, c: string): void {
throw new Error("needs implementation");
}

public append(c: string): void {
throw new Error("needs implementation");
}

public remove(n: number): void {
throw new Error("needs implementation");
}

public concat(other: Name): void {
throw new Error("needs implementation");
}

}

0 comments on commit 2b4aa56

Please sign in to comment.