Due: Friday, 18 September 2020 (AoE)
The main purpose of this problem set is to give you an opportunity to learn how to write simple programs in the TypeScript language and ecosystem.
This is an individual assignment, but you may seek help about installing and using the TypeScript toolset, or about the TypeScript language itself. See the section on getting help on the course description web page.
Visual Studio Code will be the required IDE for this course. VSC is an excellent code editor. It includes on-the-fly syntax highlighting, autocompletion, and error highlighting, and is available for Windows, macOS, and Linux. If you have not used VSC before, watch one or more of the official Getting Started videos.
If you are using Windows, in Settings, go to "Choose Default Apps by File Type" and associate .ts files with VSC.
VSC includes a git integration. You will not need to use git for this assignment, but you will need it for later assignments and for the project. In the unlikely event that you have not used git before, you will need to learn git, since it is required for this course. There are many tutorials out there; we will put up our own a little later in the semester.
tsconfig.jsonfiles in it.
npm install. You can do this in VSC (the default key is C-~ or C-`). The installation may take a minute or two, depending on your internet connection. After installation, your folder should now have a
node_modulesfolder in it, and a
package-lock.jsonfile in it.
src/folder within your assignment. Typescript files use the .ts extension. Your unit tests for foo.ts should be named foo.spec.ts and are kept in the src directory.
Earth is being invaded by martians. Here's a description of the Martian fleet:
Note: When we say the fleet of a spaceship, we mean her daughter ships and all their fleets.
Your task is to build a TypeScript module that exports the following:
droneFactory: () -> Spaceshipthat creates a new drone
mothershipFactory: (name: string, crew: Martian, daughterShips?: Spaceship) -> Spaceshipthat creates a new mother ship
martianFactory: (name: string) -> Martianthat creates a new Martian
getDaughterShips: (ship:Spaceship) -> Spaceshipthat returns the daughter ships of a ship. If the ship is a drone, this function should return an empty array.
hasMork: (ship:Spaceship) -> booleanthat returns
trueif and only if the spaceship has a Martian named "Mork" in its crew.
totalMorks: (ship:Spaceship) -> numberthat returns the total number of Martians named "Mork" that are in the crews of either the spaceship or its fleet
shipWithoutDrones : (ship:Spaceship) -> Spaceshipthat returns another spaceship just like the original, except that all of its daughters that are drones have been removed. If the ship specified is not a mother ship, this function should return
shipWithoutDeepDrones : (ship:Spaceship) -> Spaceshipthat returns another spaceship just like the original, except that all of the drones in its fleet have been removed. If the ship specified is not a mother ship, this function should return
shipWithoutDeepMorks : (ship:Spaceship) -> Spaceshipthat returns another spaceship just like the original, except that every ship in its fleet who has a crewmember named "Mork" has been removed. When a ship is removed from the fleet, so are all its daughters and their fleets. If the ship initially specified as the parameter to this function contains Mork, this function should return
shipWithoutMorksButPromoteTheirDaughters : (ship:Spaceship) -> Spaceshipthat returns another ship just like the original, except that all of its daughters who have a crewmember named "Mork" have been removed. However, when a daughter is removed from the fleet, each of its daughters (a grand-daughter of the given spaceship) are promoted to become a daughter of the given spaceship, even if it has a Mork in its crew. Note that this function ONLY checks the daughter ships of the ship specified (not the entire fleet). If the ship initially specified as the parameter to this function contains Mork, this function should return
Your task also includes writing unit tests for these functions.
Put your solution in a file called
index.ts and your unit
tests in a file called
index.spec.ts, both in the
src folder. These two files should contain your entire submission.
To get you started, the zip file we gave you contains sample files
src/index.spec.ts . Pay
special attention to the examples in the sample
index.spec.ts . These examples not only show the format of a
typical test file, but they also illustrate some important properties of the
TypeScript language that you might skip over as you read.
Your assignment will be graded on a series of automated functional tests, making sure that it implements the specification above, and it will also be inspected manually for general coding conventions and correctness. This assignment will be graded on a very lenient "pass/fail" basis and will not directly contribute to your course grade.
In accordance with the "reasonable person principle," we reserve the right to audit your code and correct any marks that are improperly assigned by the automated functional test suite, for instance, due to your code incorrectly following the specification, but passing the test. We would encourage you to spend your time correctly implementing the assignment, and not trying to force it to pass the test, even if it is not following the spirit of the assignment.
Submit your solution using Gradescope.
To create your account on Gradescope, you should click "Login with school credentials," select "myNortheastern Username," and log in.
After logging in, select "Enroll in course" and use entry code
95B8E2. Within Gradescope, upload your
index.spec.ts to Gradescope. Please note that your submisison should not print anything to console.log.
After you submit your assignment, Gradescope will automatically compile your code and run our suite of automated tests. You should verify that the
result that Gradescope generates is what you expect. Your code is built and tested in an Ubuntu 18 VM, using NodeJS v14.
You may resubmit to Gradescope an unlimited number of times before the deadline.
Please be reminded of the course late submisison policy: assignments will be accepted up to 48 hours past the deadline at a penalty of 50%, and not accepted beyond 48 hours past the deadline.