When making classes for basic objects you need to not forget to add some extra variables for the values that don't come with inputs like lap number for a pod.
Checkpoint class
classCheckpoint
{
publicint id;
public Point position;
public Checkpoint prev, next;
publicCheckpoint(int id) {
this.id = id;
position = new Point(Console.ReadLine());
}
}
Pod class
classPod
{
Point position;
Vector velocity, direction;
float angle;
int lap;
Checkpoint target;
publicCheckpoint() { }
publicvoidUpdate() {
position = new Point(Console.ReadLine());
velocity = new Vector(Console.ReadLine());
angle = float.Parse(Console.ReadLine());
int ncpId = int.Parse(Console.ReadLine());
if (ncpId != target.id) {
target = target.next;
if (target.id == 1)
lap++;
}
}
}
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.