Question: JAVA- Complete this code as the comments describe: import java.util.*; class Person { private String lastName; private String firstName; private int age; public Person(String first,
JAVA- Complete this code as the comments describe:
import java.util.*;
class Person {
private String lastName;
private String firstName;
private int age;
public Person(String first, String last, int age) {
lastName = last;
firstName = first;
age = age;
}
@Override
public String toString() {
String result = "";
//!!! return "person info: firstName lastName, age"
return result;
}
public int getAge() {
return age;
}
}
public class Lab7
{
public static void main(String[] args) {
testStack();
testQueue();
}
private static void testStack() {
Stack
//!!! add five persons with different names and ages
//!!! print contents of the stack
//!!! find a person with smallest age and prints the person
}
private static void testQueue() {
Queue
PriorityQueue
//!!! Add 10 random numbers (0 ~ 99) to queue and priority queue
//!!! Each queue should have different random numbers
//!!! Use offer for queues
//!!! Find the smallest number from all.
//!!! Use an iterator for intQueue1.
//!!! Remove all elements from both queues
//!!! For each element removed, print content of the queues
//!!! Use remove for queue
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
