So I have 3 objects (Car, Employee, and Department)
A car can belong to either an employee or department - it cannot belong to both. The car can also be available (meaning it hasn't been assigned to either an employee or department).
How can I represent this in a class?
At the moment I have something like this, but it doesn't stop the car from belonging to both employee and department.
How can I have something like:
This is probably a stupid question.
//Feels embarrassed
A car can belong to either an employee or department - it cannot belong to both. The car can also be available (meaning it hasn't been assigned to either an employee or department).
How can I represent this in a class?
At the moment I have something like this, but it doesn't stop the car from belonging to both employee and department.
Code:
class Car {
public int CarId {get; set;}
.
.
.
.
public Employee Emp {get;set;}
public Department Dept {get;set;}
}
How can I have something like:
Code:
public [Employee || Department] Owner {get;set;}
//Feels embarrassed