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
Your corporation hosts a Web site at the static public IP address 92.110.30.123.
ivann1987 [24]

Answer:

Check the explanation

Explanation:

In line with the question, we can now derive that:

The router's outside interface IP address will be 92.110.30.65.

The router's inside interface IP address will be 192.168.11.254.

The Web site's IP public IP address will be 92.110.30.123.

The private IP address of the backup Web server will be 192.168.11.110.

and when we say IP address, it stands for Internet Protocol, it is a set of usual predefined rules which are utilized to administrate the manner to which data packets are sent over the internet. An IP address, which is typically just identified as an IP, is a sequence of figures used to uniquely recognize a computer/device on a particular network or on the internet space.

7 0
2 years ago
Lenny is a cheese packer at Cheddar Express. He is paid $.52 for every case of cheese he packs and loads onto delivery pallets M
Natali [406]

Answer:

oof.

Explanation:

6 0
2 years ago
Sarah is a busy real estate agent with a growing clientele. She is looking to purchase a new computer and software so that she c
lyudmila [28]

Answer:

ASP.NET ,C#.NET,SQLServer,HTML,JavaScript

Explanation:

To build any web based application we need one presentation layer(HTML)

and for client side scripting JavaScript.

ServerSide ASP.NET Technology  and C#.NET to write your business layer

Sql programming to store data in sql server

5 0
2 years ago
When you must give something up in order to get something else it's called
matrenka [14]

Answer:

Opportunity cost refers to what you have to give up to buy what you want in terms of other goods or services. When economists use the word “cost,” we usually mean opportunity cost.

Explanation:

please give me a heart

8 0
2 years ago
A brochure describing the benefits of a product to the target audience is an example of which type of document?
Setler79 [48]

Answer:

The answer is "a design proposal "

Explanation:

The brochure is just a paper document that could be embedded in design, poster, and flyer. It is also often used for advertising purposes. Its design process, which becomes an imaginative process through which requirements were identified and process designed for the desires, that's why the above-given option is a correct and wrong choice can be defined as follows:

  • The choice design brief is wrong because it is a written explanation.
  • The choice design critique is wrong because it used to analyze the design.
  • In choice design medium, it is processed in which design is prepared, that's why it is wrong.
8 0
3 years ago
Read 2 more answers
Other questions:
  • Luentifying message rullidl Upuuns
    12·1 answer
  • What can be entered in a search box to find data? data size a name relevance purpose
    5·2 answers
  • To enter a typed number into a cell, you press Tab or Backspace?​
    7·2 answers
  • Least common multiple of 78,90, and 140
    10·2 answers
  • How long does it take to be placed in a class on flvs?
    14·1 answer
  • Edison wants to purchase a new computer and go to the Caribbean for spring break. The computer is priced at $1,299, and the vaca
    15·1 answer
  • 2. Give technical terms for
    13·1 answer
  • 1. List three tabs that make up the Ribbon
    14·1 answer
  • PLS HELP MEE it's due in 2 minutes​
    7·1 answer
  • Pls help me po:{<br><br> I need the answer lang po talaga , pls:{
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!