You have been tasked by the claims department of Isaacs Asteroid Exploration Co. to improve the performance of their land claim system.
Every time a new asteroid is ready for exploitation speculators are invited to stake their claim to a plot of land. The asteroid's land is divided into 4 sided plots. Speculators claim the land by specifying its dimensions.
Your goal is to develop a performant system to handle the land rush that has in the past caused the website to crash.
The unit of measure is 100 meters but can be ignored in these tasks.
Complete the implementation of the Plot
struct which comprises 4 coord structs (which it accepts in its constructor).
Implement the ClaimsHandler.StakeClaim()
method to allow a claim to be registered.
Implement the ClaimsHandler.IsClaimStaked()
method to determine whether a claim has been staked.
var ch = new ClaimsHandler();
ch.StakeClaim(new Plot(new Coord(1,1), new Coord(2,1), new Coord(1,2), new Coord(2,2)));
ch.IsClaimStaked(new Plot(new Coord(1,1), new Coord(2,1), new Coord(1,2), new Coord(2,2)));
// => true
Implement the ClaimsHandler.IsLastClaim()
method to compare the current claim with the previous one.
var ch = new ClaimsHandler();
ch.StakeClaim(new Plot(new Coord(1,1), new Coord(2,1), new Coord(1,2), new Coord(2,2)));
ch.IsLastClaim(new Plot(new Coord(1,1), new Coord(2,1), new Coord(1,2), new Coord(2,2)));
// => true
Implement the ClaimsHandler.GetClaimWithLongestSide()
method to examine all registered claims and return the plot with the longest side.
var ch = new ClaimsHandler();
ch.StakeClaim(new Plot(new Coord(1,1), new Coord(2,1), new Coord(1,2), new Coord(2,2)));
ch.StakeClaim(new Plot(new Coord(1,1), new Coord(20,1), new Coord(1,2), new Coord(2,2)));
ch.GetClaimWithLongestSide();
// => new Plot(new Coord(1,1), new Coord(20,1), new Coord(1,2), new Coord(2,2))