PRN212_-_PE_-_SP_2025_-_Block_5_3856.webp
Izumi99

PRN212_-_PE_-_SP_2025_-_Block_5_3856.webp

  • Media owner Izumi99
  • Ngày thêm
Kizspy.me
Zoom
4. Declare a delegate SpeedAdjuster that takes an int parameter (current speed) and returns an int
(new speed).
5. Create a static class SpeedCalculator with two static methods:
int IncreaseSpeed(int currentSpeed): increases the speed by 10 (returns currentSpeed +10).
int DecreaseSpeed(int currentSpeed): decreases the speed by 5 (returns currentSpeed-5).
6. Write a simple Main method to test your code.
- Students are required to write a simple Main function to test the functionalities of the program.
Here's a suggestion for writing the Main method to test your code:
class Program {
static void Main() {
Car car new Car("Toyota", 100);
Bicycle bicycle = new Bicycle("Phoenix", 20);
SpeedAdjuster adjuster
SpeedCalculator. IncreaseSpeed;
car. Speed adjuster (car. Speed);
Console.WriteLine(car. DescribeMovement());
adjuster = SpeedCalculator. DecreaseSpeed;
bicycle. Speed
adjuster (bicycle. Speed);
Console.WriteLine(bicycle. DescribeMovement());
Expected output when you use the Main function suggested above:
+ 100%
Close
Chưa có bình luận nào.

Thông tin

Category
PRN212
Thêm bởi
Izumi99
Ngày thêm
Lượt xem
4,776
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom