samedi 20 mai 2023

Java - design pattern State [closed]

I am doing a java program,in this I have a class "Booking" where I have a state with 3 possibilities: "Check-in not done", "Ongoing", "Check-out done". The default state is the first one ("Check-in not done"), then the user change the state until the last one ("Check-out done").

I want that a message is printed on screen only once when the state is reached. I had thought of using the desing pattern "State" to implement this. Is it a correct choice? If it is how can write this part of code?

Aucun commentaire:

Enregistrer un commentaire