summaryrefslogtreecommitdiff
path: root/slips/src/app/Marina/Domain/Slip.cs
blob: 6b8a9b7ecdfc02eb234b679dcdab6a3a5a3ae0c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using Marina.Domain.Exceptions;
using Marina.Domain.Interfaces;

namespace Marina.Domain {
	public class Slip : DomainObject, ISlip {
		public Slip( long id, IDock dock, int width, int length, bool isLeased ) : base( id ) {
			_dock = dock;
			_width = width;
			_length = length;
			_isLeased = isLeased;
		}

		public IDock Dock() {
			return _dock;
		}

		public ILocation Location() {
			return _dock.Location( );
		}

		public int Width() {
			return _width;
		}

		public int Length() {
			return _length;
		}

		public ISlipLease LeaseTo( ICustomer customer, ILeaseDuration duration ) {
			if ( !IsLeased( ) ) {
				_isLeased = true;
				return new SlipLease( this, duration );
			}
			throw new SlipIsAlreadyLeasedException( );
		}

		public bool IsLeased() {
			return _isLeased;
		}

		private readonly IDock _dock;
		private readonly int _width;
		private readonly int _length;
		private bool _isLeased;
	}
}