Public WaterLevel CanalLockWaterLevel ") Next, design your public API, but leave the methods not implemented: public enum WaterLevel Then, add a new class and name it CanalLock. You'll build a console application to test your CanalLock class. Your methods implement the safety measures. The class should also support properties to read the current state of both gates and the water level. It would have other commands to raise or lower the water. A CanalLock class would support commands to open or close either gate. You can build a C# class to model this behavior. To open a gate, the water level in the lock must match the water level outside the gate being opened. The water level can be changed only when both gates are closed. Safety measures make sure an operator can't create a dangerous situation in the canal. Once the water level matches that side, the gate on the exit side opens. Once in the lock, the water level is changed to match the water level where the boat will leave the lock. In its normal operation, a boat enters one of the gates while the water level in the lock matches the water level on the side the boat enters. A lock has two gates and some mechanism to change the water level. Briefly, a canal lock is a device that raises and lowers boats as they travel between two stretches of water at different levels. In this tutorial, you'll build a C# class that simulates a canal lock. The C# 9 compiler is available starting with Visual Studio 2019 version 16.8 or the. You'll need to set up your machine to run. Leverage compiler diagnostics to validate your implementation. Implement those patterns using C#'s pattern matching features.Express your object oriented classes using data patterns.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |