1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Masteriza [31]
3 years ago
5

Now that the classList Array has been implemented, we need to create methods to access the list items.

Computers and Technology
1 answer:
natima [27]3 years ago
7 0

The following code will be applied to Create the following static methods for the Student class

<u>Explanation:</u>

/* Note: Array index starts from 0 in java so ,, user ask for 1 index then the position will be i-1 , below program is based on this concept if you dont want this way just remove -1 from classList.get(i-1).getName(); ,and classList.add(i-1,student); */

/* ClassListTester.java */

public class ClassListTester

{

public static void main(String[] args)

{

//You don't need to change anything here, but feel free to add more Students!

Student alan = new Student("Alan", 11);

Student kevin = new Student("Kevin", 10);

Student annie = new Student("Annie", 12);

System.out.println(Student.printClassList());

System.out.println(Student.getLastStudent());

System.out.println(Student.getStudent(1));

Student.addStudent(2, new Student("Trevor", 12));

System.out.println(Student.printClassList());

System.out.println(Student.getClassSize());

}

}

/* Student.java */

import java.util.ArrayList;

public class Student

{

private String name;

private int grade;

//Implement classList here:

private static ArrayList<Student> classList = new ArrayList<Student>();

public Student(String name, int grade)

{

this.name = name;

this.grade = grade;

classList.add(this);

}

public String getName()

{

return this.name;

}

//Add the static methods here:

public static String printClassList()

{

String names = "";

for(Student name: classList)

{

names+= name.getName() + "\n";

}

return "Student Class List:\n" + names;

}  

public static String getLastStudent() {

// index run from 0 so last student will be size -1

return classList.get(classList.size()-1).getName();

}

public static String getStudent(int i) {

// array starts from 0 so i-1 will be the student

return classList.get(i-1).getName();

}

public static void addStudent(int i, Student student) {

// array starts from 0 so, we add at i-1 position

classList.add(i-1,student);

// remove extra student

classList.remove(classList.size()-1);

}  

public static int getClassSize() {

return classList.size();

}

}

You might be interested in
Dotted Decimal Notation was created to______________. Group of answer choices provide an alternative to IP addressing express ea
BaLLatris [955]

Answer:

Both b and c

Explanation:

Dotted Decimal notation is a presentation of numerical data which is expressed as decimal numbers separated by full stops. Dotted decimal notation expresses each eight bit sections of 32 bit numbers as decimal value. It provides convenient notation which is easy to understand by the people who are IT experts.

3 0
3 years ago
How are special characters added to a Word document? Check all that apply.
MrRissso [65]

It kinda depends on what you mean by special characters

7 0
3 years ago
Read 2 more answers
Suppose I have two DFAs D1, D2 and I perform the product construction on them to get a DFA for the union of their languages. Wha
Musya8 [376]

Answer:

Explanation:

If L(D1) = L(D2), the D has every state being final

If L(D1) = L¯(D2), the D has every state being final

If L(D1) = ∅, then L(D) = L(D2).

If L(D1)=Σ, L(D) = L(D2)

8 0
3 years ago
Voice and fingerprint _______ can significantly improve the security of physical devices and provide stronger authentication for
zysi [14]

Answer:

biometrics

Explanation:

Voice and fingerprint <u>biometrics</u> can significantly improve the security of physical devices and provide stronger authentication for remote access or cloud services.

6 0
3 years ago
Joe, a user, wants his desktop RAID configured to allow the fastest speed and the most storage capacity. His desktop has three h
kirill115 [55]

Answer:

A. 0

Explanation:

The technician should configure the RAID 0 for Joe.

RAID 0 also referred to as the striped volume or stripe set is configured to allow the fastest speed and the most storage capacity by splitting data evenly across multiple (at least two) disks, without redundancy and parity information.

Also, RAID 0 isn't fault tolerant, as failure of one drive will cause the entire array to fail thereby causing total data loss.

7 0
3 years ago
Other questions:
  • Given the following business scenario, create a Crow's Foot ERD using a specialization hierarchy if appropriate. Granite Sales C
    12·1 answer
  • Drive-by hacking is a computer attack where an attacker accesses a wireless computer network, intercepts data, uses network serv
    5·1 answer
  • Why do we need to send emails
    12·1 answer
  • Wireless networks usually use ____ signals to send data.
    11·2 answers
  • Your friend Margo is considering what type of display to purchase with her new desktop computer and she asks you for advice. You
    14·1 answer
  • What type of code do computers typically use to operate? A. CSS B. HTML 5 C. HTML D. Binary
    12·2 answers
  • Write Tic tac toe program in python for beginners pls
    10·1 answer
  • 01110101<br> +00100100<br> 00010001
    8·1 answer
  • How can you say that a painting is real? ​
    7·2 answers
  • Discribe two ways you can zoom in and out from an image
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!