Create a new arraylist call peoplelist that contains people

Assignment Help JAVA Programming
Reference no: EM131599425

Question1. Solving this question will help you understand Collections in java.

Copy the previous application to a new folder, open it in NetBeans and rename it to "CollectionsExample"

2.1 (20) Create a new ArrayList call "peopleList" that contains People objects.
ArrayList<People> peopleList = new ArrayList();
Then create one student Object, one Staff, and one Faculty object. Add all three objects to "peopleList"
Hint:
Student student1 = new Student("James", "Bond", new Date("01/01/1995"), 111222333);
peopleList.add(student1);
Then use a for-loop to call all objects' Display function to print out the contents of each objects.

2.2 (20) In order to compare different object, you need to implement a Comparator for class "People". Please create a FirstNameComparator which will implement the java "Comparator" Interface.
Hint declare a new class: public class FirstNameComparator implements Comparator<People>
And then override the "compare" method of that Interface in the method, you should compare the firstName String.
@Override
public int compare(People p1, People p2) {
return p1.getFirstName().compareTo(p2.getFirstName());
}

2.3 (20)refer to 2.2, write a new class "SSNComparator", and implement the java "Comparator" Interface. In that class, override the "compare" method to compare the SSN.

2.4 (20) Collection sorting method in your main function:

2.4.1 Please use Collections and FirstNameComparator to sort your "peopleList" by FirstName and print out your "peopleList".

2.4.2 Please use Collections and SSNComparator to sort your "peopleList" by SSN and print out your "peopleList".

2.5 (20)ArrayList other methods:

2.5.1 ArrayList AddAll method:
Create a new ArrayList<People> PeopleListClone object, use its AddAll method to Add "peopleList" to itself twice. You will have 6 elements for PeopleListClone. Display all six elements.

2.5.2 ArrayList Remove method.
Use remove method in "PeopleListClone" to remove the student objects in this ArrayList, two student elements will be removed. Display all four elements left.

2.5.3 ArrayList Reverse method. Use Collections.reverse method to reverse the PeopleListClone and then display all elements after reverse.

2.5.4 ArrayList Clear method. Use PeopleListClone.clear() method to empty the ArrayList, then display to user that now this array contains 0 element.

Attachment:- Assignment.zip

Reference no: EM131599425

Questions Cloud

Proportion of females in the sample : On a specific day, a store in the mall took a random sample of 163 shoppers and recorded the proportion of females in the sample.
Hypothesis testing yields credible results : Question: Based on the above five steps, how would you ensure that your Hypothesis testing yields credible results?
Interpret anova results please : Sum of Squares between groups 559400 with df of 2 and mean square 279700. Sum of squares within groups 9483400 with df of 27 and mean square
Ci for the population mean : the researchers sample had a SD of 1.2 years. construct a 99% CI for the population mean
Create a new arraylist call peoplelist that contains people : Create a new ArrayList call peopleList" that contains People objects
Public complaint against a police department : ?Research news sources (articles, newspapers, Internet, etc) and find an example of a public complaint against a police department.
Literary analysis of critical theme in either film or novel : English Essay Assignment: Choice One. Literary Analysis of a Critical Theme in Either the Film or Novel of Stephen King's The Shining.
Roi data set : For each of the 2 majors calculate the mean, median, minimum, maximum, range, and standard deviation for the columns 'Cost' and '30-Year ROI'.
Least squares estimates : Calculate the following least squares estimates. Carry out all calculations exactly and round to 3 decimal places the final answers only.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Develop a reservation system program for specific flights.

develop a reservation system program for specific flights. A customer should be able to select from one of four categories of seats on flights from RDU to any of at least three other destinations. Based on the user input of seat type and destination,..

  Overriding the equals method

Use the equals method, which Player inherits from the Object class, to determine whether two players are the same. Are the results what you expect?

  Calculates the total annual compensation of a salesperson

Write a Java application using NetBeans Integrated Development Environment (IDE) that calculates the total annual compensation of a salesperson. Consider the following factors: A salesperson will earn a fixed salary of $100,000

  Write a java application program called largest.java

Write a Java application program called Largest.java that inputs a series of 10 single-digit numbers and determines and prints the largest of the numbers

  Write a java program that calculates and displays the result

Write a Java program that calculates and displays the results of addition, subtraction, multiplication, division, modulus, bitwise &, or bitwise operation on two integer values input by the user.

  Compute the monthly commission earned by a salesperson

Write a CommissionCalculator class to compute the monthly commission earned by a salesperson, given the salesperson's name, total sales, years

  Correct the methods code

Correct the methods code - System out println

  What is the smallest exponent

In storing number in a string of 16 bits, the first bit is used for the sign of the number, and the next 5 bits store the exponent plus the bias, and the remaining 10 bits store the mantissa. The bias is 15.

  Create a separate class for the selected product

Create a separate class for the selected product that holds the item number, the name of the product, the department in which the product belongs, the number of units in stock, and the price of each unit. You must use the product and class name th..

  Write class encapsulating the concept of weather forecast

Write a class encapsulating the concept of the weather forecast, assuming that it has the given attributes: the temperature and the sky conditions, which could be sunny, snowy, cloudy, or rainy.

  Create empty tree and test

CMPT 270.3 Intersession 2016 Assignment. In this assignment you are to use TDD to implement a linked list data structure class. You will write a java program lListTester.java and a class lList

  Values that occur just once

This list has some values that occur just once (1, 3, 4, 11, 13, 18), some values that occur twice (9, 16), some values that occur three times (14, 19) and a single value that occurs four times (7). Therefore, the call of list.maxCount() should re..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd