subject
Computers and Technology, 20.10.2020 20:01 Eylul30

Import java. io. File; import java. io. FileNotFoundException;
import java. util. Scanner;
public class OwlPopulation extends Owl{
private String fileName;
private Owl[] data;
public void populateData() throws FileNotFoundException{
File f = new File(fileName);
Scanner scanner = new Scanner(f);
int numLines = 0;
while(scanner. hasNextLine()){
numLines++;
String s = scanner. nextLine();
}
scanner. close();
data = new Owl[numLines]; //data is is allocated the exact amount of space it needs
scanner = new Scanner(f);
//TODO: Populate the data with owls constructed from the lines of the file given
}
public OwlPopulation(String fileName) throws FileNotFoundException{
//TODO: Populate the class variables in OwlPopulation
}
public double averageAge(){
//TODO: implement
return -1;
}
public Owl getYoungest(){
//TODO: implement
return null;
}
public Owl getHeaviest(){
//TODO: implement
return null;
}
public String toString(){
//TODO: implement
return null;
}
public boolean containsOwl(Owl other){
//TODO: method you can implement as a helper function to your merge method
return false;
}
public void merge(OwlPopulation other){
//TODO: a brief overview of what you can do to implement this method is given below:
//1) determine (and store) the distinct owls in the other population.
//2) make a new data array to hold the correct number of owls for the merged population
//3) copy over the distinct owls from each population to the data array
//4) set the new data array to "this" data (where is the merged population? what happens to the original populations?)
}
public int popSize(){
return data. length;
}
public static void main(String[] args) {
try {
//The following should run when you are complete. Feel free to comment out as you see fit while you work.
OwlPopulation pop1 = new OwlPopulation("owlPopulation1.csv") ;
System. out. println(pop1);
System. out. println(pop1.popSize());
OwlPopulation pop2 = new OwlPopulation("owlPopulation2.csv") ;
System. out. println(pop2);
System. out. println(pop2.popSize());
pop1.merge(pop2);
System. out. println(pop1);
System. out. println(pop1.popSize());
}
catch (FileNotFoundException f){
System. out. println("File not found.");
}
}
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 00:40
Reading characters and strings from the keyboard: consider the following c++ program 1. #include 2. #include 3. using namespace std; 4. mystring1 5. 6. int main() 7. { 8. 9. string mystring1, mystring2; mychar1 10. 11. 12. char mychar1, mychar2; 13. 14. cout< < "enter a string: "; mychar2 15. 16. cin> > mystring1; // 17. cin.get(mychar1); 18. cin> > mychar2; 19. getline(cin,mystring2); mystring2 20. 21. 22. cout<
Answers: 1
question
Computers and Technology, 23.06.2019 06:20
What is a point-in-time measurement of system performance?
Answers: 3
question
Computers and Technology, 23.06.2019 15:00
1. which of the following statements are true about routers and routing on the internet. choose two answers. a. protocols ensure that a single path between two computers is established before sending packets over it. b. routers are hierarchical and the "root" router is responsible for communicating to sub-routers the best paths for them to route internet traffic. c. a packet traveling between two computers on the internet may be rerouted many times along the way or even lost or "dropped". d. routers act independently and route packets as they see fit.
Answers: 2
question
Computers and Technology, 23.06.2019 20:30
If chris has a car liability insurance, what damage would he be covered for
Answers: 1
You know the right answer?
Import java. io. File; import java. io. FileNotFoundException;
import java. util. Scanner;
Questions
question
Mathematics, 19.01.2020 01:31
question
Business, 19.01.2020 01:31
question
Mathematics, 19.01.2020 01:31
question
Mathematics, 19.01.2020 01:31
Questions on the website: 13722363