UNPKG

tohamyticketmodule

Version:

AAIB ITI 42

87 lines (82 loc) 2.3 kB
class Tickets { constructor(ticketId = 0, seatNumber = 0, flightNumber = 0, departureAirport = "", arrivalAirport = "", travellingDate = "" ) { this.ticketId = ticketId this.seatNumber = seatNumber; this.flightNumber = flightNumber; this.departureAirport = departureAirport; this.arrivalAirport = arrivalAirport; this.travellingDate = travellingDate; } display() { console.log(this); } get({ id, sn, fn, da, aa, td }) { var tid = this.ticketId, snum = this.seatNumber, fnum = this.flightNumber, depa = this.departureAirport, arra = this.arrivalAirport, trad = this.travellingDate if (id == tid) { if (sn) { console.log(`Your seat number is ${snum}`); } else if (fn) { console.log(`Your flight number is ${fnum}`); } else if (da) { console.log(`Your departure airport is ${depa}`); } else if (aa) { console.log(`Your arrival airport is ${arra}`); } else if (td) { console.log(`Your travelling date is ${trad}`); } } else { console.log("Please enter a valid ticket Id"); } } update({ id, sn, fn, da, aa, td }) { var tid = this.ticketId, snum = this.seatNumber, fnum = this.flightNumber, depa = this.departureAirport, arra = this.arrivalAirport, trad = this.travellingDate tid = id snum = sn, fnum = fn, depa = da, arra = aa, trad = td if (sn) { this.seatNumber = snum; } else if (fn) { this.flightNumber = fnum; } else if (da) { this.departureAirport = depa; } else if (aa) { this.arrivalAirport = arra; } else if (td) { this.travellingDate = trad; } } } module.exports = Tickets;