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 15:00
Atool that matches persoal skills qualities interests and talets to a career is called a
Answers: 1
question
Computers and Technology, 22.06.2019 23:30
Jaina and tomas are being considered as new tenants in an apartment. the landlord looks at their creditworthiness because he wants to be sure his new tenant pays the rent on time and in full. the table below summarizes the information that was on their applications. application information questions jaina tomas how many years have you had your job? 5 2 what is your monthly salary? $1,850 $2,500 how many credit cards do you have? 4 1 how much debt do you have? $13,000 $7,000 how many times were you late with payments on credit cards in the past year? 5 1 who will the landlord decide to be more creditworthy and why? tomas because the ratio of his debt to income is less. jaina because she has had her job longer, which makes her look more stable. jaina because she has more credit cards available to her. tomas because he makes more money per month.
Answers: 2
question
Computers and Technology, 23.06.2019 19:30
Amitha writes up a one-page summary of a novel during her summer internship at a publishing company. when she reads over the page, she realizes she used the word “foreshadow” seven times, and she would like to reduce the repetition. which tool would best amitha solve this problem?
Answers: 3
question
Computers and Technology, 24.06.2019 00:00
Consider the series where in this problem you must attempt to use the ratio test to decide whether the series converges. compute enter the numerical value of the limit l if it converges, inf if it diverges to infinity, minf if it diverges to negative infinity, or div if it diverges but not to infinity or negative infinity.
Answers: 1
You know the right answer?
Import java. io. File; import java. io. FileNotFoundException;
import java. util. Scanner;
Questions