CSA Exam Practice
public DownloadInfo getDownloadInfo(String title) {
for(DownloadInfo d: downloadList){
if(d.getTitle().equals(title)){
return d;
}
}
return null;
}
public void updateDownloads(List<String> titles){
for(String title: titles){
if()
}
}
public TokenPass(int playerCount){
board = new int[playerCount];
for(int i = 0; i < playerCount; i++){
board[i] = 1 + (int) (Math.random() * 10);
}
currentPlayer = (int)(Math.random() * playerCount);
}
public void distributeCurrentPlayer(){
for(int i = currentPlayer; i < board.length; i++){
board[i]++;
}
}
public SkyView(int numRows, int numCols, double[] scanned){
view = new double[numRows][numCols];
int i = 0;
for(int r = 0; r < numRows; r++){
if (r % 2 == 0){
for(int c = 0; c < numCols; c++){
view[r][c] = scanned[i]
i++;
}
}
else{
for(int c = numCols - 1; c >= 0; c--){
view[r][c] = scanned[i]
i++;
}
}
}
}
public double getAverage(int startRow, int endRow, int startCol, int endCol){
double sum = 0;
int i = 0;
for(int r = startRow; r <= endRow; r++){
for(int c = startCol; c<= endCol; c++){
sum += view[r][c];
i++;
}
}
return sum/i;
}
public boolean findEmployeeForChild(Child c){
for(Employee e: employees){
if(e.childrenAssigned() < maxRatio && e.canTeach(c.getAge())){
e.assignChild(c);
return true;
}
}
return false;
}
public boolean runDayCare(){
for(Child c: children){
if(!findEmployeeForChild(c))
return false;
}
return true;
}
public boolean addChild(Child c){
if(findEmployeeForChild(c)){
children.add(c);
return true;
}
return false;
}
public class Player extends Person {
private String position;
public Player(String s, int a, String pos){
super(s, a);
position = pos;
}
public void changePosition(String pos){
position = pos;
}
}
public static String getFirstName(String name){
int i = name.indexOf(" ")
return name.substring(0, i);
}
public static String getLastName(String name){
int i = name.indexOf(" ");
return name.substring(i+1, name.length());
}
public static int countVowels(String name){
int count = 0;
for(int i = 0; i < name.length(); i++){
if(name.substring(i, i+1).equals(a))
}
}