using System; using Projectile; class Program { static void Main() { var proj = new Projectile.Projectile(theta: 45, velocity: 25, height: 0); while (proj.Height >= 0) { Console.WriteLine($"x = {proj.X:F2}, y = {proj.Y:F2}"); proj.Update(0.1); } } }
using Projectile; class Cannon { private readonly float _angle; private readonly float _velocity; private readonly float _height; public Cannon(float angle, float velocity, float height) { _angle = angle; _velocity = velocity; _height = height; } public Projectile.Projectile Fire() { return new Projectile.Projectile(_angle, _velocity, _height); } } class Program { static void Main() { var cannon = new Cannon(angle: 30, velocity: 20, height: 10); var proj = cannon.Fire(); while(proj.Height >= 0) { // do something } } }This code defines a Cannon class that can fire a projectile at a specific angle, velocity, and height. It uses the Projectile library to create the projectile and update its position at each time step.