Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In a file Laptop.java, create a Laptop class and make the class implement the Comparable interface. The member variables should include the following laptop configuration

In a file Laptop.java, create a Laptop class and make the class implement the Comparable interface. The member variables should include the following laptop configuration details cpu, ram, hdd, graphics card (boolean 1=yes/0=no), screen size, weight, battery life (hours), and price. The constructor for the class should allow the initialization of all the member variables. The constructor for a Laptop instance should also calculate a score variable out of 10, which will be calculated as follows:

laptopScore = (2 * cpu/cpuMax) + (2 * ram/ramMax) + (1 * hdd/hddMax) + (graphics) + (1 * screen/screenMax) + (1 * weight/weightMax) + (1 * battery/batteryMax) + (1 * price/priceMax)

Here, use the following max values: cpuMax = 3.0, ramMax = 32, hddMax = 2048, screenMax = 17.0, weightMax = 6, batteryMax = 9, priceMax = 2000

Create a method randomLaptopCreator to create a list of 5 laptops with randomly generated configurations for each of the specification variables. Specify the range for the random values for each specification item based on a (reasonably assumed) min value and the max value. You will also create a toString method, which will print out the configuration of a laptop (similar to the octagon problem above) including the laptop score. The overridden compareTo method in the Laptop class should compare the configurations of the laptops based on the laptop score. Next, you will use the Arrays.sort method to sort the list of randomly generated laptops, and print them out (using the toString method) in ascending order.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Strategic Database Technology Management For The Year 2000

Authors: Alan Simon

1st Edition

155860264X, 978-1558602649

More Books

Students also viewed these Databases questions

Question

Identify and describe a suggested outline of a business plan.

Answered: 1 week ago