Question
Please do this , I am also posting my existing code All actions should take place in main (function and/or class) using the functions available
Please do this , I am also posting my existing code
All actions should take place in main (function and/or class) using the functions available in Image and Application classes. Printing should also happen in main - that is, do not have System.out.print... anywhere outside main.
B. Image modification. Create two images, each with at least three applications. After those are created, print out all their information to make sure the creation process works well. Fix any problems you may encounter.
Existing code :
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package hciproject; import java.util.*;
/** * * @author */ public class HCIproject {
/** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Image image1, image2; image1 = new Image(); image2 = new Image(); AppObject a, b, c, d; a = new AppObject(); b = new AppObject(); c = new AppObject(); d = new AppObject(); a.setName("MS Office"); a.setDiskSize(2524); a.setCoresUsed(3); a.setRamSize(1399); b.setName("Firefox "); b.setDiskSize(122); b.setCoresUsed(1); b.setRamSize(1577); c.setName("Acrobat "); c.setDiskSize(682); c.setCoresUsed(2); c.setRamSize(889); d.setName("AutoCAD "); d.setDiskSize(51229); d.setCoresUsed(6); d.setRamSize(32000); image1.setName("Sales Laptops"); image1.addApplication(a, 200); image1.addApplication(b, 0); image1.addApplication(c, 100); image2.setName("Engineering Workstations"); image2.addApplication(a, 200); image2.addApplication(b, 0); image2.addApplication(c, 100); image2.addApplication(d, 500); printImage(image1); printImage(image2); image1.setApplicationData(a, 100); image1.setApplicationData(b, 50); image1.setApplicationData(c, 200); image2.setApplicationData(a, 300); image2.setApplicationData(b, 75); image2.setApplicationData(c, 500); image2.setApplicationData(d, 1000); System.out.println(""); System.out.println("==================="); System.out.println(""); System.out.println("-------------------"); printImage(image1); printImage(image2); image1.removeApplication(a); image1.removeApplication(c); image2.removeApplication(b); System.out.println(""); System.out.println("==================="); System.out.println(""); System.out.println("-------------------"); printImage(image1); printImage(image2); } public static void printImage(Image im){ System.out.println("Printing contents of \"" + im.getName() + "\" image:"); System.out.println("\tName \t\tRAM \tCores \tDisk Space \tExtra Disk Space"); for(int i = 0; i < im.getNumberOfApplications(); i++){ AppObject app; app = im.getApplication(i); System.out.print("\t" + app.getName() + "\t" + app.getDiskSize() + "\t" + app.getCoresUsed() + "\t" + app.getRamSize()); System.out.println("\t\t" + im.getApplicationExtraData(i)); } System.out.println("-------------------"); }
}
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