Computers and Technology
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.");
}
}
}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 01:00, labrandonanderson00
Ap practice - performance task response the ap create performance task asks you to write about an abstraction that you developed and wrote into your code. most of the time that means identifying a function or procedure you wrote to "manage complexity" in your program. here is the actual prompt from the create performance task: 2d. capture and paste a program code segment that contains an abstraction you developed individually on your own (marked with a rectangle). this abstraction must integrate mathematical and logical concepts. explain how your abstraction manage the complexity of your program. (must not exceed 200 words) below is a segment of code from an "under the sea" program with a rectangle drawn around a portion of the code identifying an abstraction. imagine that you wrote this and are composing an ap response about how this abstraction manages complexity. (note: ignore the requirement that the abstraction integrate "mathematical and logical concepts" for this practice response. just write about managing complexity). explain how the abstraction marked with the rectangle in the code above manage complexity of this program. write your response here submit
Answers: 2
image
Computers and Technology, 23.06.2019 01:30, marmar72
Negative methods of behavior correction include all but this: sarcasm verbal abuse setting an example for proper behavior humiliation
Answers: 1
image
Computers and Technology, 23.06.2019 14:30, qveenvslayin
The basic work area of the computer is it screen that you when you first fire up your computer
Answers: 1
image
Computers and Technology, 23.06.2019 15:00, hunteryolanda82
Based on the current economic situation do you expect the employment demand for graduating engineers to increase or decrease? explain the basis for your answer. with a significant economic recovery, what do you think will happen to future enrollments in graduating engineering programs?
Answers: 1
Do you know the correct answer?
Import java. io. File; import java. io. FileNotFoundException;
import java. util. Scanner;

Questions in other subjects:

Konu
Mathematics, 03.03.2021 18:00
Konu
Mathematics, 03.03.2021 18:00
Konu
Health, 03.03.2021 18:00