Commit Graph

3 Commits

Author SHA1 Message Date
b70bad851e Use encapsulation principal in CivilVehicle
Since every occurrence of collide should set
	currentAccident and broken for all cars, use
	setCurrentAccident() for both cars in collide()
	which sets both values.

Signed-off-by: HeshamTB <hishaminv@gmail.com>
2020-11-07 12:35:35 +03:00
f8b5e79187 Add ref to street in every Accident
Add Street Object for Accident as location
	for Instances of Accident.

	Removed 'isInAccident()' from 'Breakable' interface
	The idea is from Previous suggested UML that replaces
	Broken and Accident with getStatus() that gives info about
	Breakable object. isBroken() now returns 1 if its eaither in
	Accident or Broken. Can check getCurrentAccident() for null.

Signed-off-by: HeshamTB <hishaminv@gmail.com>

Signed-off-by: HeshamTB <hishaminv@gmail.com>
2020-11-06 22:36:01 +03:00
eb94de2754 Remake Vehicle classes
- Abstract class CivilVehicle that implements Breakable and
	contains all common fields of vehicles. Now for example,
	Sedan <- CivilVehicle <- Vehicle
		      ^
		  Breakable
	The breakable methods are mostly implemented in CivilVehicle
	Except getTimeToFix() which is defined in subclasses of
	CivilVehicle.

	- Breakable interface:
	The method collide() now returns instance of Accident instead of
	void

Signed-off-by: HeshamTB <hishaminv@gmail.com>
2020-10-21 11:35:19 +03:00