model
stringclasses 13
values | specification
stringlengths 18
187
| ocl
stringlengths 36
305
|
---|---|---|
class Player()
class Match(startDate: Date, endDate: Date, playMove(p,m), getScore())
class Tournament(name: String, startDate: Date, endDate: Date, acceptPlayer(p), removePlayer(p), schedule())
association Match 'matches *' -- 'tournament 1' Tournament
association Match 'matches *' -- 'players *' Player
association Player 'players *' -- 'tournaments *' Tournament | All Matches in a Tournament occur within the Tournament's time frame. | context Tournament inv: self.matches->forAll(m:Match | m.startDate.after(self.startDate) and m.endDate.before(self.endDate)) |
class Player()
class Match(startDate: Date, endDate: Date, playMove(p,m), getScore())
class Tournament(name: String, startDate: Date, endDate: Date, acceptPlayer(p), removePlayer(p), schedule())
association Match 'matches *' -- 'tournament 1' Tournament
association Match 'matches *' -- 'players *' Player
association Player 'players *' -- 'tournaments *' Tournament | Each Tournament conducts at least one Match on the first day of the Tournament. | context Tournament inv: self.matches->exists(m:Match | m.startDate.equals(self.startDate)) |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | Every customer who enters a loyalty program must be of legal age. | context Customer inv: self.age >= 18 |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | Male customers must be approached using the title Mr.. | context Customer inv: self.isMale implies self.title = Mr. |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | The number of valid cards for every customer must be equal to the number of programs in which the customer participates. | context Customer inv: self.cards->select(valid=true)->size()=self.programs->size() |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | The validFrom date of customer cards should be earlier than goodThru. | context CustomerCard inv: self.validFrom < self.goodThru |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | The birth date of the owner of a customer card must not be in the future. | context CustomerCard inv: self.owner.dateOfBirth <> future |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | The owner of a customer card must participate in at least one loyalty program. | context CustomerCard inv: self.owner.programs->size() >= 1 |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | There must be at least one transaction for a customer card with at least 100 points. | context CustomerCard inv: self.transactions->select(point >= 100)->size()>= 1 |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | The service level of each membership must be a service level known to the loyalty program. | context Membership inv: self.currentLevel->includes(self.program.levels) |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | The participants of a membership must have the correct card belonging to this membership. | context Membership inv: self.participants.cards->includes(self.card) |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | The color of a membership's card must match the service level of the membership. | context Membership inv: self.card.color = self.currentLevel.name |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | Memberships must not have associated accounts. | context Membership inv: self.account->isEmpty() |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | Loyalty programs must offer at least one service to their customers. | context LoyaltyProgram inv: self.partners.deliveredServices->size() >= 1 |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | If none of the services offered in a loyalty program credits or debits the loyalty accounts: , then these instances are useless and should not be present. | context LoyaltyProgram inv: partners.deliveredServices->forAll(pointsEarned = 0 and pointsBurned = 0) implies Membership.account->isEmpty() |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | The name of the first level must be Silver. | context LoyaltyProgram inv: self.levels->first().name = Silver |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | There must exist at least one service level with the name basic. | context LoyaltyProgram inv: self.level->exists(name = 'basic') |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | The number of participants in a loyalty program must be less than 10: ,000. | context LoyaltyProgram inv: self.participants->size()<10000 |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | The number of the loyalty account must be unique within a loyalty program. | context LoyaltyProgram inv: self.Membership.account->isUnique(acc|acc.numbers) |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | The names of all customers of a loyalty program must be different. | context LoyaltyProgram inv: self.participants.name->forAll(c1,c2|c1.name<>c2.name) |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | The maximum age of participants in loyalty programs is 70. | context LoyaltyProgram inv: self.participants->forAll(age<= 70) |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | There may be only one loyalty account that has a number lower than 10: ,000. | context LoyaltyProgram inv: self.Membership.account->one(number < 10,000) |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | The attribute numberOfCustomers of class ProgramPartner must be equal to the number of customers who participate in one or more loyalty programs offered by this program partner. | context ProgramPartner inv: self.numberOfCustomers=programs.participants->asSet()->size() |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | A maximum of 10: ,000 points may be earned using services of one partner. | context ProgramPartner inv: self.deliveredServices.pointsEarned<=10,000 |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | All cards that generate transactions on the loyalty account must have the same owner. | context LoyaltyAccount inv: self.transactions.cards.owner->asSet()->size() = 1 |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | If the points earned in a loyalty account is greater than zero: , there exists a transaction with more than zero points. | context LoyaltyAccount inv: points > 0 implies transactions->exists(t | t .points > 0) |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | There must be one transaction with exactly 500 points. | context Transaction inv: self.transaction->select(point = 500)->size()=1 |
class LoyaltyProgram(name: String, enroll(), getServices(): Service)
class ProgramPartner(numberOfCustomers: Integer, name: String)
class Membership()
class Customer(name: String, title: String, isMale: Boolean, dateOfBirth: Integer, age: Integer, cAge())
class ServiceLevel(name: String)
class Service(condition: Boolean, pointsEarned: Integer, pointsBurned: Integer, description: String, serviceNr: Integer)
class CustomerCard(valid: Boolean, validFrom: Date, goodThru: Date, color: Color, printedName: String)
class LoyaltyAccount(points: Integer, numbers: Integer, earn(), burn(), isEmpty())
class Transaction(date: String, amount: Integer, point: Integer, programs())
association LoyaltyProgram 'programs *' -- 'participants *' Customer
association LoyaltyProgram 'programs 1..*' -- 'partners 1..*' ProgramPartner
association LoyaltyProgram 'program 1' -- 'levels 1..*' ServiceLevel
association LoyaltyProgram 'programs 0..1' -- 'membership 0..1' Membership
association Customer 'owner 1' -- 'cards *' CustomerCard
association ProgramPartner 'partner 0..1' -- 'deliveredServices *' Service
association ServiceLevel 'currentLevel 1' -- 'currentLevel *' Membership
association ServiceLevel 'level 0..1' -- 'availableServices *' Service
association Membership --> 'card 1' CustomerCard
association Membership --> 'account 0..1' LoyaltyAccount
association CustomerCard 'card 1' -- 'transactions *' Transaction
association LoyaltyAccount 'account 1' -- 'transactions *' Transaction
association Service 'generatedBy 0..1' -- 'transactions *' Transaction | The available services for a service level must be offered by a partner of the loyalty program to which the service level belongs. | context ServiceLevel inv: self.program.partners->includesAll(self.availableServices.partner) |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | The age of employees must be greater than or equal to 18 | context Employee inv: self.age() >= 18 |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | The supervisor of an employee must be older than the employee | context Employee inv: self.supervisor->notEmpty() implies self.age() > self.supervisor.age() |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | The salary of an employee cannot be greater than the salary of his/her supervisor | context Employee inv: self.supervisor->notEmpty() implies self.salary < self.supervisor.salary |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | The hire date of employees must be greater than their birth date | context Employee inv: self.hireDate > self.birthDate |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | The start date of an employe as manager of a department must be greater than his/her hire date | context Employee inv: self.manages->notEmpty() implies self.manages.startDate > self.hireDate |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | A supervisor must be hired before every employee s/he supervises | context Employee inv: self.subordinates->notEmpty() implies self.subordinates->forall( e | e.hireDate > self.hireDate ) |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | The manager of a department must be an employee of the department | context Department inv: self.worksFor->includes(self.manages.employee) |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | The SSN of employees is an identifer (or a key) | context Employee inv: Employee.allInstances->forAll( e1, e2 | e1 <> e2 implies e1.SSN <> e2.SSN ) |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | The name and relationship of dependents is a partial identifer: they are unique among all dependents of an employee | context Employee inv: self.dependents->notEmpty() implies self.dependents->forAll( e1, e2 | e1 <> e2 implies ( e1.name <> e2.name or e1.relationship <> e2.relationship )) |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | The location of a project must be in one of the locations of its department | context Project inv: self.controls.locations->includes(self.location) |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | The attribute nbrEmployees in Department keeps the number of employees that works for the department | context Department inv: self.nbrEmployees = self.worksFor->size() |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | An employee works at most in 4 projects | context Employee inv: self.worksOn->size() <= 4 |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | An employee may only work on projects controlled by the department in which s/he works | context Employee inv: self.worksFor.controls->includesAll(self.worksOn.project) |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | An employee works at least 30h/week and at most 50 h/week on all its projects | context Employee inv: let totHours: Integer = self.worksOn->collect(hours)->sum() in totHours >= 30 and totHours <=50 |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | A project can have at most 2 employees working on the project less than 10 hours | context Project inv: self.worksOn->select( hours < 10 )->size() <= 2 |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | Only department managers can work less than 5 hours on a project | context Employee inv: self.worksOn->select( hours < 5 )->notEmpty() implies Department.allInstances()->collect(manages.employee)-> includes(self) |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | The only managers that can work less than 5 hours on a department project must be an employee of the department itself | context Employee inv: self.worksOn->select( hours < 5 )->notEmpty() implies self.worksFor.manages.employee=self |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | Employees without subordinates must work at least 10 hours on every project they work | context Employee inv: self.subordinates->isEmpty() implies self.worksOn->forAll( hours >=10 ) |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | The manager of a department must work at least 5 hours on all projects controlled by the department | context Department inv: self.controls->forall( p:Project | self.manages.employee.worksOn->select(hours >= 5)->contains(p) ) |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | An employee cannot supervise him/herself | context Employee inv: self.subordinates->excludes(self) |
class Employee(SSN: Integer, firstName: String, lastName: String, birthDate: Date, sex: String, salary: Integer, address: String, hireDate: Date, age())
class Department(number: Integer, name: String, locations: String, nbrEmployees: Integer)
class Project(number: Integer, name: String, location: String)
class Manages(startDate: Date)
class WorksOn(hours: Integer)
class Dependent(name: String, relationship: String, sex: String, birthDate: Date
association Employee 'manager 1' -- 'department 0..1' Department: (Employee, Department) .. Manages
association Employee 'employees 4..*' -- 'department 1' Department: WorksFor
association Employee 'owned 1..*' -- 'worksOn 1..*' Project: (Employee, Project) .. WorksOn
association Employee 'supervisor 0..1' -- 'subordinates 0..*' Employee: Supervision
association Employee 'employee 1' -- 'dependents 0..*' Dependent
association Department 'department 1..*' -- 'controls 1' Project | The supervision relationship must not be cyclic | context Employee def: allSubordinates = self.subordinates->union(self->subordinates->collect(e:Employee | e.allSubordinates)) inv: self.allSubordinates->exludes(self) |
class Date(date: String)
class Car(regNum: String)
class CarGroup(category: String)
class Branch(address: String)
class Quote(value: Integer)
class Rental(id: String, price: Real, state: String, startingDate: Date, endingDate: Date)
class Customer(id: String, name: String, birthday: Date, licenseExpData: Date, premium: Boolean, discount: Integer)
class BlackListed(blackListedDate: Date)
association Car 'cars 1..*' -- 'carGroup 1' CarGroup
association Car 'car 0..1' -- 'rentalAgreement *' Rental
association CarGroup 'low 0..1' -- 'high 0..1' CarGroup
association CarGroup 'carGroup 1..*' -- 'branch 1..*' Branch
association Branch 'pickUpBranch 1' -- 'pickUpRental *' Rental
association Branch 'dropOffBranch 1' -- 'dropOffRental *' Rental
association Rental 'rental 1..*' -- 'driver 1..*' Customer
association BlackListed --|> Customer
| Rental ending date must be later or equal than starting date | context Rental inv: self.startingdate <= self.endingDate |
class Date(date: String)
class Car(regNum: String)
class CarGroup(category: String)
class Branch(address: String)
class Quote(value: Integer)
class Rental(id: String, price: Real, state: String, startingDate: Date, endingDate: Date)
class Customer(id: String, name: String, birthday: Date, licenseExpData: Date, premium: Boolean, discount: Integer)
class BlackListed(blackListedDate: Date)
association Car 'cars 1..*' -- 'carGroup 1' CarGroup
association Car 'car 0..1' -- 'rentalAgreement *' Rental
association CarGroup 'low 0..1' -- 'high 0..1' CarGroup
association CarGroup 'carGroup 1..*' -- 'branch 1..*' Branch
association Branch 'pickUpBranch 1' -- 'pickUpRental *' Rental
association Branch 'dropOffBranch 1' -- 'dropOffRental *' Rental
association Rental 'rental 1..*' -- 'driver 1..*' Customer
association BlackListed --|> Customer
| On Mondays the agency is close (so no rentals starting on a Monday) | context Rental inv: not self.startingDate.dayOfTheWeek()<>DayOftheWeek::Monday |
class Date(date: String)
class Car(regNum: String)
class CarGroup(category: String)
class Branch(address: String)
class Quote(value: Integer)
class Rental(id: String, price: Real, state: String, startingDate: Date, endingDate: Date)
class Customer(id: String, name: String, birthday: Date, licenseExpData: Date, premium: Boolean, discount: Integer)
class BlackListed(blackListedDate: Date)
association Car 'cars 1..*' -- 'carGroup 1' CarGroup
association Car 'car 0..1' -- 'rentalAgreement *' Rental
association CarGroup 'low 0..1' -- 'high 0..1' CarGroup
association CarGroup 'carGroup 1..*' -- 'branch 1..*' Branch
association Branch 'pickUpBranch 1' -- 'pickUpRental *' Rental
association Branch 'dropOffBranch 1' -- 'dropOffRental *' Rental
association Rental 'rental 1..*' -- 'driver 1..*' Customer
association BlackListed --|> Customer
| Minimum duration of a rental is 10 hours | context Rental inv: (self.endDate - self.startingDate).hours() >= 10 |
class Date(date: String)
class Car(regNum: String)
class CarGroup(category: String)
class Branch(address: String)
class Quote(value: Integer)
class Rental(id: String, price: Real, state: String, startingDate: Date, endingDate: Date)
class Customer(id: String, name: String, birthday: Date, licenseExpData: Date, premium: Boolean, discount: Integer)
class BlackListed(blackListedDate: Date)
association Car 'cars 1..*' -- 'carGroup 1' CarGroup
association Car 'car 0..1' -- 'rentalAgreement *' Rental
association CarGroup 'low 0..1' -- 'high 0..1' CarGroup
association CarGroup 'carGroup 1..*' -- 'branch 1..*' Branch
association Branch 'pickUpBranch 1' -- 'pickUpRental *' Rental
association Branch 'dropOffBranch 1' -- 'dropOffRental *' Rental
association Rental 'rental 1..*' -- 'driver 1..*' Customer
association BlackListed --|> Customer
| Last Friday of each month the agency is closed | context Rental inv: not self.startingdate = self.startingdate.getMonth().last('Friday') |
class Airport(name: String)
class Flight(departTime: Date, arrivalTime: Date, duration: Date, maxNrPassenger: Integer)
class Airline(name: String)
class Passenger(minAge: Integer, age: Integer, needsAssistance: Boolean, book(f: Flight))
association Airport 'origin 1' -- 'departingFlights *' Flight
association Airport 'destination 1' -- 'arrivingFlights *' Flight
association Flight 'flights *' -- 'airline 1' Airline
association Flight 'flight 1' -- '(ordered) passengers *' Passenger
association Passenger 'CEO 0..1' -- 'airline 0..1' Airline
| All flight objects must have a duration attribute that is less than four | context Flight inv: self.duration < 4 |
class Airport(name: String)
class Flight(departTime: Date, arrivalTime: Date, duration: Date, maxNrPassenger: Integer)
class Airline(name: String)
class Passenger(minAge: Integer, age: Integer, needsAssistance: Boolean, book(f: Flight))
association Airport 'origin 1' -- 'departingFlights *' Flight
association Airport 'destination 1' -- 'arrivingFlights *' Flight
association Flight 'flights *' -- 'airline 1' Airline
association Flight 'flight 1' -- '(ordered) passengers *' Passenger
association Passenger 'CEO 0..1' -- 'airline 0..1' Airline
| The maximum number of passengers on any flight may not exceed 1000 | context Flight inv: self.maxNrPassenger <= 1000 |
class Airport(name: String)
class Flight(departTime: Date, arrivalTime: Date, duration: Date, maxNrPassenger: Integer)
class Airline(name: String)
class Passenger(minAge: Integer, age: Integer, needsAssistance: Boolean, book(f: Flight))
association Airport 'origin 1' -- 'departingFlights *' Flight
association Airport 'destination 1' -- 'arrivingFlights *' Flight
association Flight 'flights *' -- 'airline 1' Airline
association Flight 'flight 1' -- '(ordered) passengers *' Passenger
association Passenger 'CEO 0..1' -- 'airline 0..1' Airline
| For every passenger the age attribute must be greater than or equal to the class attribute minAge | context Passenger inv: self.age >= self.minAge |
class Airport(name: String)
class Flight(departTime: Date, arrivalTime: Date, duration: Date, maxNrPassenger: Integer)
class Airline(name: String)
class Passenger(minAge: Integer, age: Integer, needsAssistance: Boolean, book(f: Flight))
association Airport 'origin 1' -- 'departingFlights *' Flight
association Airport 'destination 1' -- 'arrivingFlights *' Flight
association Flight 'flights *' -- 'airline 1' Airline
association Flight 'flight 1' -- '(ordered) passengers *' Passenger
association Passenger 'CEO 0..1' -- 'airline 0..1' Airline
| The duration attribute of all flight objects must be equal to the difference between the arrivalTime attribute and the departTime attribute | context Flight inv: self.duration = self.arrivalTime - self.departTime |
class Airport(name: String)
class Flight(departTime: Date, arrivalTime: Date, duration: Date, maxNrPassenger: Integer)
class Airline(name: String)
class Passenger(minAge: Integer, age: Integer, needsAssistance: Boolean, book(f: Flight))
association Airport 'origin 1' -- 'departingFlights *' Flight
association Airport 'destination 1' -- 'arrivingFlights *' Flight
association Flight 'flights *' -- 'airline 1' Airline
association Flight 'flight 1' -- '(ordered) passengers *' Passenger
association Passenger 'CEO 0..1' -- 'airline 0..1' Airline
| The airport from which a flight is leaving is different from the destination airport | context Flight inv: self.origin <> self.destination |
class Airport(name: String)
class Flight(departTime: Date, arrivalTime: Date, duration: Date, maxNrPassenger: Integer)
class Airline(name: String)
class Passenger(minAge: Integer, age: Integer, needsAssistance: Boolean, book(f: Flight))
association Airport 'origin 1' -- 'departingFlights *' Flight
association Airport 'destination 1' -- 'arrivingFlights *' Flight
association Flight 'flights *' -- 'airline 1' Airline
association Flight 'flight 1' -- '(ordered) passengers *' Passenger
association Passenger 'CEO 0..1' -- 'airline 0..1' Airline
| For every flight the name of the airport from which it is leaving must be 'Amsterdam' | context Flight inv: self.origin.name = 'Amsterdam' |
class Airport(name: String)
class Flight(departTime: Date, arrivalTime: Date, duration: Date, maxNrPassenger: Integer)
class Airline(name: String)
class Passenger(minAge: Integer, age: Integer, needsAssistance: Boolean, book(f: Flight))
association Airport 'origin 1' -- 'departingFlights *' Flight
association Airport 'destination 1' -- 'arrivingFlights *' Flight
association Flight 'flights *' -- 'airline 1' Airline
association Flight 'flight 1' -- '(ordered) passengers *' Passenger
association Passenger 'CEO 0..1' -- 'airline 0..1' Airline
| For every flight the name of the airline must be 'KLM' | context Flight inv: self.airline.name = 'KLM' |
class Unit(name: String, symbol: String, description: String, definitionURI: String)
class SystemOfUnits(name String, symbol: String, description: String, definitionURI: String)
class SystemOfQuantities(name String, symbol: String, description: String, definitionURI: String)
class QuantityKind(name String, symbol: String, description: String, definitionURI: String)
class Prefix(name: String, symbol: String, factor: Real)
class AffineConversionUnit(factor: Real, offset: Integer)
class UnitFactor(exponent: Real)
class GeneralConversionUnit(expression: String, expressionLanguageURI: String)
class DerivedUnit()
class SimpleUnit()
class ConversionBasedUnit()
class PrefixedUnit()
class LinearConversionUnit()
association Unit --> 'quantityKind 0..1' QuantityKind
association SystemOfUnits --> 'systemofQuantities *' SystemOfQuantities
association SystemOfUnits --> 'unit *' Unit
association SystemOfUnits --> 'baseUnit *' Unit
association SystemOfUnits --> 'prefix *' Prefix
association SystemOfQuantities --> 'baseQuantityKind *' QuantityKind
association UnitFactor --> 'unit 1' Unit
association DerivedUnit --> 'factor 1..*' UnitFactor
association ConversionBasedUnit --> 'referenceUnit 1' Unit
association PrefixedUnit --> 'prefix 1' Prefix
association DerivedUnit --|> Unit
association SimpleUnit --|> Unit
association ConversionBasedUnit --|> Unit
association PrefixedUnit --|> ConversionBasedUnit
association LinearConverionUnit --|> ConversionBasedUnit
association AffineConversionUnit --|> ConversionBasedUnit
association GeneralConversionUnit --|> ConversionBasedUnit | The referenceUnit shall not be a PrefixedUnit | context PrefixedUnit inv: not referenceUnit->oclIsTypeOf(PrefixedUnit) |
class Unit(name: String, symbol: String, description: String, definitionURI: String)
class SystemOfUnits(name String, symbol: String, description: String, definitionURI: String)
class SystemOfQuantities(name String, symbol: String, description: String, definitionURI: String)
class QuantityKind(name String, symbol: String, description: String, definitionURI: String)
class Prefix(name: String, symbol: String, factor: Real)
class AffineConversionUnit(factor: Real, offset: Integer)
class UnitFactor(exponent: Real)
class GeneralConversionUnit(expression: String, expressionLanguageURI: String)
class DerivedUnit()
class SimpleUnit()
class ConversionBasedUnit()
class PrefixedUnit()
class LinearConversionUnit()
association Unit --> 'quantityKind 0..1' QuantityKind
association SystemOfUnits --> 'systemofQuantities *' SystemOfQuantities
association SystemOfUnits --> 'unit *' Unit
association SystemOfUnits --> 'baseUnit *' Unit
association SystemOfUnits --> 'prefix *' Prefix
association SystemOfQuantities --> 'baseQuantityKind *' QuantityKind
association UnitFactor --> 'unit 1' Unit
association DerivedUnit --> 'factor 1..*' UnitFactor
association ConversionBasedUnit --> 'referenceUnit 1' Unit
association PrefixedUnit --> 'prefix 1' Prefix
association DerivedUnit --|> Unit
association SimpleUnit --|> Unit
association ConversionBasedUnit --|> Unit
association PrefixedUnit --|> ConversionBasedUnit
association LinearConverionUnit --|> ConversionBasedUnit
association AffineConversionUnit --|> ConversionBasedUnit
association GeneralConversionUnit --|> ConversionBasedUnit | In a coherent system of units, there is only one base unit for each base quantity. | context SystemOfUnits inv: self.systemOfQuantities.baseQuantityKind.size() = self.baseUnit->size() = 1 |
class Order(id: Integer, quantity: Integer, state: String, Order(prd: Product, qty: Integer): OclVoid, cancel(): Boolean, invoice(): Boolean)
class Product(id: Integer, stock: Integer, Product(): Boolean, supply(qty: Integer): Boolean, release(qty: Integer): Boolean)
association Order 'order 1' --> 'product 1' Product: OrderProduct | The stock of a Product is always a natural number, i.e., it is a positive Integer. This also ensures the definedness of the stock. | context Product inv isNat: self.stock >= 0 |
class Order(id: Integer, quantity: Integer, state: String, Order(prd: Product, qty: Integer): OclVoid, cancel(): Boolean, invoice(): Boolean)
class Product(id: Integer, stock: Integer, Product(): Boolean, supply(qty: Integer): Boolean, release(qty: Integer): Boolean)
association Order 'order 1' --> 'product 1' Product: OrderProduct | The Product id is unique. | context Product inv idUnique: Product::allInstances()->forAll(p1:Product, p2:Product | p1.id <> p2.id) |
class Order(id: Integer, quantity: Integer, state: String, Order(prd: Product, qty: Integer): OclVoid, cancel(): Boolean, invoice(): Boolean)
class Product(id: Integer, stock: Integer, Product(): Boolean, supply(qty: Integer): Boolean, release(qty: Integer): Boolean)
association Order 'order 1' --> 'product 1' Product: OrderProduct | The quantity of an Order is always a natural number, i.e., it is a positive Integer. This also ensures the definedness of the quantity. | context Order inv isNat: self.quantity >= 0 |
class Order(id: Integer, quantity: Integer, state: String, Order(prd: Product, qty: Integer): OclVoid, cancel(): Boolean, invoice(): Boolean)
class Product(id: Integer, stock: Integer, Product(): Boolean, supply(qty: Integer): Boolean, release(qty: Integer): Boolean)
association Order 'order 1' --> 'product 1' Product: OrderProduct | The state of an Order should either be `pending' or `invoiced'. | context Order inv stateRange: (self.state = 'pending') or (self.state = 'invoiced') |
class Order(id: Integer, quantity: Integer, state: String, Order(prd: Product, qty: Integer): OclVoid, cancel(): Boolean, invoice(): Boolean)
class Product(id: Integer, stock: Integer, Product(): Boolean, supply(qty: Integer): Boolean, release(qty: Integer): Boolean)
association Order 'order 1' --> 'product 1' Product: OrderProduct | The Order id is unique. | context Order inv idUnique: Order::allInstances()->forAll(o1:Order, o2:Order | o1.id <> o2.id) |
class Order(id: Integer, quantity: Integer, state: String, Order(prd: Product, qty: Integer): OclVoid, cancel(): Boolean, invoice(): Boolean)
class Product(id: Integer, stock: Integer, Product(): Boolean, supply(qty: Integer): Boolean, release(qty: Integer): Boolean)
association Order 'order 1' --> 'product 1' Product: OrderProduct | order(...) function creates a new Order | context Order::Order(prd:Product, qty:Integer):OclVoid pre: qty > 0 pre: self.warehouse.products->exists(x:Product | x = prd) pre: not prd.oclIsUndefined() post: self.oclIsNew() and self.quantity = qty and self.orderedProduct = prd |
class Order(id: Integer, quantity: Integer, state: String, Order(prd: Product, qty: Integer): OclVoid, cancel(): Boolean, invoice(): Boolean)
class Product(id: Integer, stock: Integer, Product(): Boolean, supply(qty: Integer): Boolean, release(qty: Integer): Boolean)
association Order 'order 1' --> 'product 1' Product: OrderProduct | The state of the order will be changed into 'invoiced' if the ordered quantity is either less or equal to the quantity which is in stock according to the reference of the ordered product. | context Order::invoice() : Boolean pre: self.state = 'pending' and self.quantity <= self.orderedProduct.stock post: self.state = 'invoiced' and self.quantity = self.quantity@pre and self.orderedProduct = self.orderedProduct@pre and self.orderedProduct.stock = self.orderedProduct@pre.stock - self.quantity |
class Order(id: Integer, quantity: Integer, state: String, Order(prd: Product, qty: Integer): OclVoid, cancel(): Boolean, invoice(): Boolean)
class Product(id: Integer, stock: Integer, Product(): Boolean, supply(qty: Integer): Boolean, release(qty: Integer): Boolean)
association Order 'order 1' --> 'product 1' Product: OrderProduct | cancel() function cancels order as an opposite operation to invoice order | context Order::cancel() : Boolean pre: self.state = 'invoiced' post: self.state = 'pending' and self.quantity = self.quantity@pre and self.product = self.product@pre and self.product.stock = self.product@pre.stock + self@pre.quantity |
class Order(id: Integer, quantity: Integer, state: String, Order(prd: Product, qty: Integer): OclVoid, cancel(): Boolean, invoice(): Boolean)
class Product(id: Integer, stock: Integer, Product(): Boolean, supply(qty: Integer): Boolean, release(qty: Integer): Boolean)
association Order 'order 1' --> 'product 1' Product: OrderProduct | supply(...) function adds quantity of the product to the stock | context Product::supply(qty:Integer):Boolean pre: qty > 0 post: self.stock = self.stock@pre + qty |
class Order(id: Integer, quantity: Integer, state: String, Order(prd: Product, qty: Integer): OclVoid, cancel(): Boolean, invoice(): Boolean)
class Product(id: Integer, stock: Integer, Product(): Boolean, supply(qty: Integer): Boolean, release(qty: Integer): Boolean)
association Order 'order 1' --> 'product 1' Product: OrderProduct | release(...) removes quantity of the product from the stock | context Product::release(qty:Integer):Boolean pre: self.stock >= qty post: self.stock = self.stock@pre - qty |
class Person(socSecNr: Integer, salary: Money, getMortgage(sum: Money, security: House))
class Mortgage(principal: Money, monthlyPayment: Money, startDate: Date, endDate: Date)
class House(value: Money)
association Person 'owner 1' -- 'houses *' House
association House 'security 1' -- 'mortgages *' Mortgage
association Mortgage 'mortgages *' -- 'borrower 1' Person | The start date for any mortgage must be before the end date. | context Mortgage: inv: startDate < endDate |
class Person(socSecNr: Integer, salary: Money, getMortgage(sum: Money, security: House))
class Mortgage(principal: Money, monthlyPayment: Money, startDate: Date, endDate: Date)
class House(value: Money)
association Person 'owner 1' -- 'houses *' House
association House 'security 1' -- 'mortgages *' Mortgage
association Mortgage 'mortgages *' -- 'borrower 1' Person | A person may have a mortgage on a house only if that house is owned by the person. | context Mortgage: inv: self.security.owner = self.borrower |
class Person(socSecNr: Integer, salary: Money, getMortgage(sum: Money, security: House))
class Mortgage(principal: Money, monthlyPayment: Money, startDate: Date, endDate: Date)
class House(value: Money)
association Person 'owner 1' -- 'houses *' House
association House 'security 1' -- 'mortgages *' Mortgage
association Mortgage 'mortgages *' -- 'borrower 1' Person | A person may have mortgage on a house only if that house is owned by the person (use Person as context). | context Person: inv: self.mortgages.security.owner->forAll(p : Person | p = self) |
class Person(socSecNr: Integer, salary: Money, getMortgage(sum: Money, security: House))
class Mortgage(principal: Money, monthlyPayment: Money, startDate: Date, endDate: Date)
class House(value: Money)
association Person 'owner 1' -- 'houses *' House
association House 'security 1' -- 'mortgages *' Mortgage
association Mortgage 'mortgages *' -- 'borrower 1' Person | The social security number of all persons must be unique (use House as a context). | context Person: inv: Person::allInstance()->forAll(p1,p2 : Person | p1<>p2 implies p1.socSecNr <> p2.socSecNr) |
class Person(socSecNr: Integer, salary: Money, getMortgage(sum: Money, security: House))
class Mortgage(principal: Money, monthlyPayment: Money, startDate: Date, endDate: Date)
class House(value: Money)
association Person 'owner 1' -- 'houses *' House
association House 'security 1' -- 'mortgages *' Mortgage
association Mortgage 'mortgages *' -- 'borrower 1' Person | The social security number of all persons must be unique (use Person as a context). | context Person::getMortgage(sum:Money, security:House) pre: self.mortgages.monthlyPayment->sum() <= self.salary * 0.30 |
class Person(socSecNr: Integer, salary: Money, getMortgage(sum: Money, security: House))
class Mortgage(principal: Money, monthlyPayment: Money, startDate: Date, endDate: Date)
class House(value: Money)
association Person 'owner 1' -- 'houses *' House
association House 'security 1' -- 'mortgages *' Mortgage
association Mortgage 'mortgages *' -- 'borrower 1' Person | A new mortgage will be allowed only when the person's income is sufficient (assume that the yearly payment must be less than 30% of the salary). | context Person::getMortgage(sum:Money, security:House) pre: security.value >= (security.mortgages.principal->sum() + sum) |
class Train(identifier: String, numOfWagons: Integer, numOfEngines: Integer, weight: Integer)
class Wagon(weight: Integer, smoking: Boolean, currentLoad: Integer, capacity: Integer)
association Train 'train 1' -- 'wagon *' Wagon
association Wagon 'succ 0..1' -- 'pred 0..1' Wagon | All the trains will have the same number of wagons. | context Train: inv: self.wagon -> size() >= 1 |
class Train(identifier: String, numOfWagons: Integer, numOfEngines: Integer, weight: Integer)
class Wagon(weight: Integer, smoking: Boolean, currentLoad: Integer, capacity: Integer)
association Train 'train 1' -- 'wagon *' Wagon
association Wagon 'succ 0..1' -- 'pred 0..1' Wagon | A wagon and its successor wagon should belong to the same train. | context Wagon: inv: self.succ -> notEmpty() implies self.succ.train = self.train |
class Train(identifier: String, numOfWagons: Integer, numOfEngines: Integer, weight: Integer)
class Wagon(weight: Integer, smoking: Boolean, currentLoad: Integer, capacity: Integer)
association Train 'train 1' -- 'wagon *' Wagon
association Wagon 'succ 0..1' -- 'pred 0..1' Wagon | The current load of a wagon cannot exceed its capacity | context Train: inv: Train.allInstances -> forAll(x:Train,y:Train | x.wagon->size() = y.wagon->size() ) |
enumeration Gender(male, female)
class Person(firstName: String, lastName: String, gender: Gender, birthDate: Date, age: Integer, isMarried: Boolean, maidenName: String, isUnemployed: Boolean, income(): Integer, currentSpouse(): Person, descendants(): Set)
class Bank(accountNo: Integer)
class Job(title: String, startDate: Date, salary: Integer)
class Company(name: String, noEmployees: Integer, stockPrice(): Real, hireEmployee(p: Person))
class Marriage(place: String, date: Date, ended: Boolean)
assocation Person 'employees *' -- 'employer *' Company: Job
assocation Person 'manager 1' -- 'managedCompanies *' Company
assocation Person 'customer 0..1' -- 'banks *' Bank
assocation Person 'parents 0..2' -- 'children *' Person
assocation Person 'wife *' -- 'husband *' Person: Marriage | Value of attribute noEmployees in instances of Company must be less than or equal to 50 | context Company inv: self.noEmployees <= 50 |
enumeration Gender(male, female)
class Person(firstName: String, lastName: String, gender: Gender, birthDate: Date, age: Integer, isMarried: Boolean, maidenName: String, isUnemployed: Boolean, income(): Integer, currentSpouse(): Person, descendants(): Set)
class Bank(accountNo: Integer)
class Job(title: String, startDate: Date, salary: Integer)
class Company(name: String, noEmployees: Integer, stockPrice(): Real, hireEmployee(p: Person))
class Marriage(place: String, date: Date, ended: Boolean)
assocation Person 'employees *' -- 'employer *' Company: Job
assocation Person 'manager 1' -- 'managedCompanies *' Company
assocation Person 'customer 0..1' -- 'banks *' Bank
assocation Person 'parents 0..2' -- 'children *' Person
assocation Person 'wife *' -- 'husband *' Person: Marriage | The stock price of companies is greater than 0 | context Company inv: self.stockPrice() > 0 |
enumeration Gender(male, female)
class Person(firstName: String, lastName: String, gender: Gender, birthDate: Date, age: Integer, isMarried: Boolean, maidenName: String, isUnemployed: Boolean, income(): Integer, currentSpouse(): Person, descendants(): Set)
class Bank(accountNo: Integer)
class Job(title: String, startDate: Date, salary: Integer)
class Company(name: String, noEmployees: Integer, stockPrice(): Real, hireEmployee(p: Person))
class Marriage(place: String, date: Date, ended: Boolean)
assocation Person 'employees *' -- 'employer *' Company: Job
assocation Person 'manager 1' -- 'managedCompanies *' Company
assocation Person 'customer 0..1' -- 'banks *' Bank
assocation Person 'parents 0..2' -- 'children *' Person
assocation Person 'wife *' -- 'husband *' Person: Marriage | Income of a person is the sum of the salaries of her jobs | context Person::income(): Integer body: self.job.salary->sum() |
enumeration Gender(male, female)
class Person(firstName: String, lastName: String, gender: Gender, birthDate: Date, age: Integer, isMarried: Boolean, maidenName: String, isUnemployed: Boolean, income(): Integer, currentSpouse(): Person, descendants(): Set)
class Bank(accountNo: Integer)
class Job(title: String, startDate: Date, salary: Integer)
class Company(name: String, noEmployees: Integer, stockPrice(): Real, hireEmployee(p: Person))
class Marriage(place: String, date: Date, ended: Boolean)
assocation Person 'employees *' -- 'employer *' Company: Job
assocation Person 'manager 1' -- 'managedCompanies *' Company
assocation Person 'customer 0..1' -- 'banks *' Bank
assocation Person 'parents 0..2' -- 'children *' Person
assocation Person 'wife *' -- 'husband *' Person: Marriage | descendants() obtains the direct and indirect descendants of a person | context Person::descendants(): Set body: result = self.children->union(self.children->collect(c | c.descendants())) |
enumeration Gender(male, female)
class Person(firstName: String, lastName: String, gender: Gender, birthDate: Date, age: Integer, isMarried: Boolean, maidenName: String, isUnemployed: Boolean, income(): Integer, currentSpouse(): Person, descendants(): Set)
class Bank(accountNo: Integer)
class Job(title: String, startDate: Date, salary: Integer)
class Company(name: String, noEmployees: Integer, stockPrice(): Real, hireEmployee(p: Person))
class Marriage(place: String, date: Date, ended: Boolean)
assocation Person 'employees *' -- 'employer *' Company: Job
assocation Person 'manager 1' -- 'managedCompanies *' Company
assocation Person 'customer 0..1' -- 'banks *' Bank
assocation Person 'parents 0..2' -- 'children *' Person
assocation Person 'wife *' -- 'husband *' Person: Marriage | Only married women can have a maiden name | context Person inv: self.maidenName <> `' implies self.gender = Gender::female and self.isMarried = true |
enumeration Gender(male, female)
class Person(firstName: String, lastName: String, gender: Gender, birthDate: Date, age: Integer, isMarried: Boolean, maidenName: String, isUnemployed: Boolean, income(): Integer, currentSpouse(): Person, descendants(): Set)
class Bank(accountNo: Integer)
class Job(title: String, startDate: Date, salary: Integer)
class Company(name: String, noEmployees: Integer, stockPrice(): Real, hireEmployee(p: Person))
class Marriage(place: String, date: Date, ended: Boolean)
assocation Person 'employees *' -- 'employer *' Company: Job
assocation Person 'manager 1' -- 'managedCompanies *' Company
assocation Person 'customer 0..1' -- 'banks *' Bank
assocation Person 'parents 0..2' -- 'children *' Person
assocation Person 'wife *' -- 'husband *' Person: Marriage | A person is currently married to at most one person | context Person inv: self.marriage[wife]->select(m | m.ended = false)->size()=1 and self.marriage[husband]->select(m | m.ended = false)->size()=1 |
enumeration Gender(male, female)
class Person(firstName: String, lastName: String, gender: Gender, birthDate: Date, age: Integer, isMarried: Boolean, maidenName: String, isUnemployed: Boolean, income(): Integer, currentSpouse(): Person, descendants(): Set)
class Bank(accountNo: Integer)
class Job(title: String, startDate: Date, salary: Integer)
class Company(name: String, noEmployees: Integer, stockPrice(): Real, hireEmployee(p: Person))
class Marriage(place: String, date: Date, ended: Boolean)
assocation Person 'employees *' -- 'employer *' Company: Job
assocation Person 'manager 1' -- 'managedCompanies *' Company
assocation Person 'customer 0..1' -- 'banks *' Bank
assocation Person 'parents 0..2' -- 'children *' Person
assocation Person 'wife *' -- 'husband *' Person: Marriage | currentSpouse() selects the current spouse of a person | context Person::currentSpouse() : Person pre: self.isMarried = true body: if gender = Gender::male self.marriage[wife]->select(m | m.ended = false).wife else self.marriage[husband]->select(m | m.ended = false).husband |
enumeration Gender(male, female)
class Person(firstName: String, lastName: String, gender: Gender, birthDate: Date, age: Integer, isMarried: Boolean, maidenName: String, isUnemployed: Boolean, income(): Integer, currentSpouse(): Person, descendants(): Set)
class Bank(accountNo: Integer)
class Job(title: String, startDate: Date, salary: Integer)
class Company(name: String, noEmployees: Integer, stockPrice(): Real, hireEmployee(p: Person))
class Marriage(place: String, date: Date, ended: Boolean)
assocation Person 'employees *' -- 'employer *' Company: Job
assocation Person 'manager 1' -- 'managedCompanies *' Company
assocation Person 'customer 0..1' -- 'banks *' Bank
assocation Person 'parents 0..2' -- 'children *' Person
assocation Person 'wife *' -- 'husband *' Person: Marriage | There are at most 100 persons | context Person inv: Person.allInstances()->size() <= 100 |
enumeration Gender(male, female)
class Person(firstName: String, lastName: String, gender: Gender, birthDate: Date, age: Integer, isMarried: Boolean, maidenName: String, isUnemployed: Boolean, income(): Integer, currentSpouse(): Person, descendants(): Set)
class Bank(accountNo: Integer)
class Job(title: String, startDate: Date, salary: Integer)
class Company(name: String, noEmployees: Integer, stockPrice(): Real, hireEmployee(p: Person))
class Marriage(place: String, date: Date, ended: Boolean)
assocation Person 'employees *' -- 'employer *' Company: Job
assocation Person 'manager 1' -- 'managedCompanies *' Company
assocation Person 'customer 0..1' -- 'banks *' Bank
assocation Person 'parents 0..2' -- 'children *' Person
assocation Person 'wife *' -- 'husband *' Person: Marriage | A company has at least one employee older than 50 | context Company inv: self.employees->select(age > 50)->notEmpty() |
enumeration Gender(male, female)
class Person(firstName: String, lastName: String, gender: Gender, birthDate: Date, age: Integer, isMarried: Boolean, maidenName: String, isUnemployed: Boolean, income(): Integer, currentSpouse(): Person, descendants(): Set)
class Bank(accountNo: Integer)
class Job(title: String, startDate: Date, salary: Integer)
class Company(name: String, noEmployees: Integer, stockPrice(): Real, hireEmployee(p: Person))
class Marriage(place: String, date: Date, ended: Boolean)
assocation Person 'employees *' -- 'employer *' Company: Job
assocation Person 'manager 1' -- 'managedCompanies *' Company
assocation Person 'customer 0..1' -- 'banks *' Bank
assocation Person 'parents 0..2' -- 'children *' Person
assocation Person 'wife *' -- 'husband *' Person: Marriage | The collection of employees of a company who are less than 18 years old is empty | context Company inv: self.employees->reject(age>=18)->isEmpty() |
enumeration Gender(male, female)
class Person(firstName: String, lastName: String, gender: Gender, birthDate: Date, age: Integer, isMarried: Boolean, maidenName: String, isUnemployed: Boolean, income(): Integer, currentSpouse(): Person, descendants(): Set)
class Bank(accountNo: Integer)
class Job(title: String, startDate: Date, salary: Integer)
class Company(name: String, noEmployees: Integer, stockPrice(): Real, hireEmployee(p: Person))
class Marriage(place: String, date: Date, ended: Boolean)
assocation Person 'employees *' -- 'employer *' Company: Job
assocation Person 'manager 1' -- 'managedCompanies *' Company
assocation Person 'customer 0..1' -- 'banks *' Bank
assocation Person 'parents 0..2' -- 'children *' Person
assocation Person 'wife *' -- 'husband *' Person: Marriage | The age of each employee is less than or equal to 65 | context Company inv: self.employees->forAll(age <= 65) |
enumeration Gender(male, female)
class Person(firstName: String, lastName: String, gender: Gender, birthDate: Date, age: Integer, isMarried: Boolean, maidenName: String, isUnemployed: Boolean, income(): Integer, currentSpouse(): Person, descendants(): Set)
class Bank(accountNo: Integer)
class Job(title: String, startDate: Date, salary: Integer)
class Company(name: String, noEmployees: Integer, stockPrice(): Real, hireEmployee(p: Person))
class Marriage(place: String, date: Date, ended: Boolean)
assocation Person 'employees *' -- 'employer *' Company: Job
assocation Person 'manager 1' -- 'managedCompanies *' Company
assocation Person 'customer 0..1' -- 'banks *' Bank
assocation Person 'parents 0..2' -- 'children *' Person
assocation Person 'wife *' -- 'husband *' Person: Marriage | All instances of persons have unique names | context Person inv: Person.allInstances()->forAll(p1, p2 | p1 <> p2 implies p1.name <> p2.name ) |
enumeration Gender(male, female)
class Person(firstName: String, lastName: String, gender: Gender, birthDate: Date, age: Integer, isMarried: Boolean, maidenName: String, isUnemployed: Boolean, income(): Integer, currentSpouse(): Person, descendants(): Set)
class Bank(accountNo: Integer)
class Job(title: String, startDate: Date, salary: Integer)
class Company(name: String, noEmployees: Integer, stockPrice(): Real, hireEmployee(p: Person))
class Marriage(place: String, date: Date, ended: Boolean)
assocation Person 'employees *' -- 'employer *' Company: Job
assocation Person 'manager 1' -- 'managedCompanies *' Company
assocation Person 'customer 0..1' -- 'banks *' Bank
assocation Person 'parents 0..2' -- 'children *' Person
assocation Person 'wife *' -- 'husband *' Person: Marriage | The firstName of at least one employee is equal to 'Jack' | context Company inv: self.employees->exists(firstName = 'Jack') |
enumeration Colour(black(): Colour, white(): Colour, red(): Colour)
class Person(name: String, age: Integer, getName(): String, birthday(), setAge(newAge:int): Integer)
class Vehicle(colour: Colour)
class Car()
class Bike()
association Person 'owner 1' -- 'fleet *' Vehicle: ownership
association Car --|> Vehicle
association Bike --|> Vehicle | A vehicle owner must be at least 18 years old | context Vehicle inv: self. owner. age >= 18 |
enumeration Colour(black(): Colour, white(): Colour, red(): Colour)
class Person(name: String, age: Integer, getName(): String, birthday(), setAge(newAge:int): Integer)
class Vehicle(colour: Colour)
class Car()
class Bike()
association Person 'owner 1' -- 'fleet *' Vehicle: ownership
association Car --|> Vehicle
association Bike --|> Vehicle | Nobody has more than 3 vehicles | context Person inv: self.fleet->size <= 3 |
enumeration Colour(black(): Colour, white(): Colour, red(): Colour)
class Person(name: String, age: Integer, getName(): String, birthday(), setAge(newAge:int): Integer)
class Vehicle(colour: Colour)
class Car()
class Bike()
association Person 'owner 1' -- 'fleet *' Vehicle: ownership
association Car --|> Vehicle
association Bike --|> Vehicle | All cars of a person are black | context Person inv: self.fleet->forAll(v | v.colour = #black) |
enumeration Colour(black(): Colour, white(): Colour, red(): Colour)
class Person(name: String, age: Integer, getName(): String, birthday(), setAge(newAge:int): Integer)
class Vehicle(colour: Colour)
class Car()
class Bike()
association Person 'owner 1' -- 'fleet *' Vehicle: ownership
association Car --|> Vehicle
association Bike --|> Vehicle | Nobody has more than 3 black vehicles | context Person inv: self.fleet->forAll(v | v.colour = #black) -> size <= 3 |
enumeration Colour(black(): Colour, white(): Colour, red(): Colour)
class Person(name: String, age: Integer, getName(): String, birthday(), setAge(newAge:int): Integer)
class Vehicle(colour: Colour)
class Car()
class Bike()
association Person 'owner 1' -- 'fleet *' Vehicle: ownership
association Car --|> Vehicle
association Bike --|> Vehicle | A person younger than 18 owns no cars | context Person inv: age<18 implies self.fleet->forAll(v | not v.oclIsKindOf(Car)) |
enumeration Colour(black(): Colour, white(): Colour, red(): Colour)
class Person(name: String, age: Integer, getName(): String, birthday(), setAge(newAge:int): Integer)
class Vehicle(colour: Colour)
class Car()
class Bike()
association Person 'owner 1' -- 'fleet *' Vehicle: ownership
association Car --|> Vehicle
association Bike --|> Vehicle | There is a red car | context Car inv: Car.allInstances()->exists(c | c.colour=#red) |