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
What part of a resource record tells a server how long the record should remain in the cache?
V125BC [204]
Time-to-live or TTL <span>tells a server how long the record should remain in the cache.
TTL is a mechanism that limits the lifetime of data in a network or a computer and prevents data packets from circulating indefinitely.
</span><span>It also improves the caching and privacy of networks and computers.</span>
8 0
4 years ago
What is APR?
omeli [17]

Answer:

APR is the Interest rate advertised by lenders.

Explanation:

APR is the annual percentage rate that is different from the interest rate. Interest rate is the rate of borrowing money. While APR is the rate which includes interest rate, processing fee and other cost that are involved in loan approving.

This cost is decided by lender, which may be equal to interest rate or greater than interest rate.

5 0
3 years ago
This rights protected document cannot be opened because the rights management feature has been disabled on your machine by Polic
erastovalidia [21]

This rights protected document cannot be opened because the rights management feature has been disabled on your machine by Policy is known to be an error message.

<h3>What is the error message about?</h3>

The Error message above is known to be one that shows that  your IT department has made a group policy in one's company's Active Directory. It is known to be one that tends to disables the use of ADRMS (Rights Management Feature) in all to all users.

Note that in the case above, one need to ask your IT department to be able to disable or make changes to the group policy so that it will not apply to the users who are said to require access secured Microsoft Office documents in any of Ansarada Rooms.

Another option is to look at documents off the network with the use of a personal computer or a mobile phone.

Hence, This rights protected document cannot be opened because the rights management feature has been disabled on your machine by Policy is known to be an error message.

Learn more about  error message from

brainly.com/question/25671653

#SPJ1

4 0
2 years ago
Select the levels of data backup.
navik [9.2K]
What levels r right and we can pick from??
6 0
4 years ago
An example of an asset that is both personal-use and personal property is:•A. A computer used solely to monitor the CEO's invest
kati45 [8]

Answer:

Option A is correct.

Explanation:

The following is an illustration of such a resource which is also personal usage as well as corporate capital, that system required primarily to track the contribution of both the Chief executive and also to execute the Form 1040.

  • Option B is incorrect because the system required exclusively to email workers concerning the operations of the organization isn't an illustration of such a resource which is both personal usage and commercial property.
  • Option C is also incorrect because it is seen that the following option is not the illustration of such a scenario.
  • Option D is incorrect because the storage facility being required through the Chief executive to preserve confidential documents is not the correct illustration of such a scenario.
  • Option E is incorrect because there are not all the resources are for the personal as well as commercial use.
7 0
3 years ago
Other questions:
  • Which sparkline type is best for displaying trends in data changes over time?
    11·1 answer
  • Mark is learning to make logos. Once he finishes learning, he plans to freelance. Which software is most preferred to create art
    16·1 answer
  • Sharon is thinking about opening a bakery. She knows she wants to set her own hours, reduce her stress and make a profit. But sh
    5·1 answer
  • Write a Java application that inputs a series of 10 integers and determines and prints the largest and smallest integer. Use a c
    12·1 answer
  • How to select the entire table in microsoft excel
    11·1 answer
  • Which of the following best define grit
    13·1 answer
  • If you have configured your prompt so that it does not show your working directory, you can use the ____ command to verify in wh
    15·1 answer
  • What is the IP address and TCP port number used by the client computer (source) that is transferring the file to gaia.cs.umass.e
    9·1 answer
  • Cyberbullying can negatively impact a victim’s <br> well-being.
    13·1 answer
  • What do other people think of e.t ( be specifc by putting a line in the story)<br><br> E.T MOVIE
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!