In a phrase: Drone racing it\'s a new \"sport\" of sorts where hobbyists create
ID: 3799340 • Letter: I
Question
In a phrase: Drone racing it's a new "sport" of sorts where hobbyists create (3D print, laser cut etc.) tiny drones capable of reaching 60mph (or more1) for the purposes of racing through an obstacle course to make this even more sci-fi-y. the drones are typically outfitted with a camera that streams directly what it sees to either a monitor (e.g. TV screen) or an HMD (Head Mounted Display, ie. "VR" headsets). While it would be cool to write a working code to control such drones for racing purpose (moving in a 3-dimensional space, sending streaming video data to be viewed remotely. etc.) this exercise is a bit simpler and has more to do with keeping track of drone racing results (as you are only taking CSS 161 after all). Class Design: Drone (Suggested Time Spent:Explanation / Answer
Code for Drone class :
abstract class Drone
{
private string name;
private double[] timearray;
public void getter(string name)
{
this.name = name;
}
public string setter()
{
return name;
}
public Drone()
{
name = 'Racing Drone';
timearray = new double(10){-1};
}
public Drone(string name)
{
this.name = name;
timearray = new double(10){-1};
}
public void addCheckPoint(double time)
{
if(isRaceCompleted())
System.out.println("Race already completed with 10 checkpoints");
else
{
for(int i=0; i<10; i++)
if(timearray[i] == -1)
{
timearray[i] = time;
break;
}
}
}
public boolean isRaceCompleted()
{
for(int i=0; i<10; i++)
if(timearray[i] == -1)
return false;
return true;
}
public double getCompletedTime()
{
double total = 0;
if(isRaceCompleted())
{
for(int i=0; i<10; i++)
total += timearray[i];
return total;
}
else
return -1;
}
}
As the class is abstract no output could be provided.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.