Question
USING BLUEJ Do folowing changes in LaptopList class 1. Remove public int countExpensive() public Laptop[] expensiveLaptops() 2. Make recursive. public void printList() public void printListReverse()
USING BLUEJ
Do folowing changes in LaptopList class
1. Remove
public int countExpensive()
public Laptop[] expensiveLaptops()
2. Make recursive.
public void printList()
public void printListReverse()
public Laptop mostExpensive()
Redesign main method in TestLaptopList class to:
1. Instantiate an object from LaptopList class
2. Invoke all of the two methods from LaptopList methods mention before
MY CODE:::
File: LaptopList.java
import java.io.*; import java.util.*;
public class LaptopList { // instance variable private ArrayList
/** * Constructor for objects of class LaptopList */ public LaptopList() throws IOException { String brand; int size; double price; laptops = new ArrayList
File: TestLaptopList.java
import java.io.*;
public class TestLaptopList { //Main method public static void main(String[] args) throws IOException { //LaptopList object LaptopList laptopsLst = new LaptopList(); //Calling methods laptopsLst.printList(); Laptop mostExpen = laptopsLst.mostExpensive(); System.out.println("Most Expensive Laptop is: Brand: " + mostExpen.getBrand() + ", Size: " + mostExpen.getSize() + ", Price: $" + mostExpen.getPrice()); //Array of expensive laptops Laptop[] expensiveArr = laptopsLst.expensiveLaptops(); System.out.println(" Most Expensive Laptops: "); for(int i=0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started