I created this project as part of the Manchester Codes software engineering course. The objective was to learn about Object Oriented Programming (OOP) principles using JavaScript, and to practise Test Driven Development.
The project contains three objects that interact with each other, allowing a 'ship' to travel across an itinerary with predetermined ports.
The project uses JavaScript, Node and Jest.
Download and initial setup:
- Fork the project repository
- Get the project link, navigate to the local folder where the project should be installed, and run
git clone
- Switch to the newly installed project folder and run
npm install
- Use command
npm test
to run the Jest test suite
The Cruise Ships project does not currently have a GUI and can be run locally using the node REPL.
- In the terminal, run
node
- Staying in the node REPL, run the following line by line to import the ship, port, and itinerary objects:
const Itinerary = require('./src/Itinerary');
const Port = require('./src/Port');
const Ship = require('./src/Ship');
- Still in the node REPL, instatiate the shop, itinerary, and ports of your choice by running:
The ship object has methods to navigate along the itinerary.
- Run
ship.currentPort.name;
- the readout should be the first port in the itinerary ('Valencia' in the example) - Run
ship.setSail();
- Run
ship.dock();
- Run
ship.currentPort.name;
- the readout should be the next port in the itinerary. - To see the previous port, run
ship.previousPort.name
Example commands to navigate the ship:
The main objective of this project was to learn about basic principles of OOP and TDD. If I was to develop this project further I would:
- Add a GUI to make user interaction easier, a better option than the node REPL for non technical users!
- Add functionality to add or remove ports from the itinerary, or to include distances and distance calculations
- The codebase could be re-purposed for other uses, for example planning a biketour or a similar journey.
Agnes Beviz