F# Car Rental Business model -


i in new f#, please have mercy. trying model a car rental business in f#. types are:
customer
driver
car
vehicletype
rentalagreement not implemented yet

my specific question can f# class have member discriminated union? car should have attribute reflects type of vehicle is...compact, sedan, truck, etc... below code far...

namespace dsl2  // du type vehicletype =  truck | compact | econ | sedan  // record type customer =  {firstname: string; lastname: string; gender: string}  //a class implicit ctor'tion type car(numdoors:int ,  make: string , year:int)  = class     member this.numdoors = numdoors     member this.make = make     member this.year = year   end  //a class explicit ctor'tion type car2 = class     val numdoors: int     val make: string     val year: int      (*first ctor*)     new (numdoors, make, year) =          {numdoors = numdoors; make = make; year = year}   end 

yes, add member class , include in constructor desired value.

// du type vehicletype =  truck | compact | econ | sedan  // record type customer =  {firstname: string; lastname: string; gender: string}  //a class implicit ctor'tion type car(numdoors:int ,  make: string , year:int)  = class     member this.numdoors = numdoors     member this.make = make     member this.year = year   end  //a class explicit ctor'tion type car2 = class     val numdoors: int     val make: string     val year: int     val du: vehicletype      (*first ctor*)     new (numdoors, make, year, cust) =          {numdoors = numdoors; make = make; year = year;  du = truck }  end 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -