/** * Lookup a Software product and return it or return a new one if not found. * * @param name the name of the software product to lookup * @return a new or existing Software product associated with this Company */ public Software lookupOrCreateSoftware(String name) { Software s = (Software) lnkSoftware.get(name); if (s == null) { s = new Software(name); lnkSoftware.put(s.getName(), s); } return s; }
public void onReceive(Object message) { if (message instanceof Requirements) { int developerId = 0; for (int i = 0; i < noOfDevelopers; i++) { developerId = i + 1; developers[i].tell( new SoftwareDevelopment(developerId, noOfTasksPerDeveloper), getContext()); } } else if (message instanceof Software) { Software developedSoftware = (Software) message; System.out.println("Developed Software : " + developedSoftware.getDevelopedComponentId()); developedComponentsCount++; if (developedComponentsCount == noOfDevelopers) { getContext().stop(); } } }
public static void main(String[] args) { ArrayList<String> List = new ArrayList<String>(); Scanner sc = new Scanner(System.in); // SETTING THE CONDITION FOR CONTINUATION String choice = "y"; while (choice.equalsIgnoreCase("y")) { // SELECTION OF PRODUCT TYPE System.out.println("Product type:(Book/Software)?"); String type = sc.nextLine(); // FOR BOOK, ENTER THE REQUIRED INFORMATION AND STORE TO DESIGNATED LOCATION if (type.equalsIgnoreCase("Book")) { System.out.println("Enter the book description:"); String descript = sc.nextLine(); System.out.println("Enter the book price:"); double price = sc.nextDouble(); sc.nextLine(); System.out.println("Enter the book author:"); String author = sc.nextLine(); Book a = new Book(); a.setAuthor(author); a.setDescription(descript); a.setPrice(price); a.setCode(type); List.add(a.toString("detail")); } else { // FOR SOFTWARE, ENTER THE REQUIRED INFORMATION AND STORE TO DESIGNATED LOCATION if (type.equalsIgnoreCase("Software")) { System.out.println("Enter the software description:"); String descript = sc.nextLine(); System.out.println("Enter the software price:"); double price = sc.nextDouble(); sc.nextLine(); System.out.println("Enter the software version:"); String version = sc.nextLine(); Software s = new Software(); s.setVersion(version); s.setDescription(descript); s.setPrice(price); s.setCode(type); List.add(s.toString("detail")); } } System.out.println("Do you wish to continue?(y/n)"); choice = sc.nextLine(); } System.out.println("PRODUCT DETAILS DISPLAYED BELOW"); System.out.println("\n"); Iterator<String> itr = List.iterator(); while (itr.hasNext()) { String in = itr.next(); System.out.println(in); } sc.close(); }
/** * liefert einen lesbaren String mit allen Parametern des ausgelieferten Androiden * * @return ausgelieferter Androide */ @Override public String toString() { return "(" + seriennummer + ", " + androide.toString() + ", " + skin.toString() + ", " + software.toString() + ", " + aktorenKit.toString() + ")"; }
protected static boolean reportError( final Electronics me, final Software controlI, final MOB mob, final String literalMessage, final String controlMessage) { if ((mob != null) && (mob.location() == CMLib.map().roomLocation(me)) && (literalMessage != null)) mob.tell(literalMessage); if (controlMessage != null) { if (controlI != null) controlI.addScreenMessage(controlMessage); else if ((mob != null) && (me != null)) mob.tell(CMLib.lang().L("A panel on @x1 reports '@x2'.", me.name(mob), controlMessage)); } return false; }
public void retrieveOperatingSystem(int id) throws Exception { String retrieveQuery = "SELECT * FROM operatingSystem WHERE id = " + id; ResultSet rs = Helper.retrieve(retrieveQuery); if (rs.next()) { super.setId(rs.getInt("id")); super.setModel(rs.getString("model")); super.setVendor(rs.getString("vendor")); super.setPrice(rs.getDouble("price")); super.setPlatform(rs.getString("platform")); super.setVersion(rs.getString("s_version")); } else { Exception NoSuchTuple = new Exception("Tuple with given id does not exists!"); throw NoSuchTuple; } }
/** * Helper to handle metadata in the document * * @throws CheckedIOException */ private void writeMetaData(PeakList peaklist) { // skip if previously done if (hasWrittenMetaData) { return; } // flag meta-data as writter hasWrittenMetaData = true; // try to get meta-data if it is available if (peaklist instanceof MzXMLPeakList) { MzXMLPeakList mzxml = (MzXMLPeakList) peaklist; msRun = mzxml.getMsRun(); } else { msRun = new MsRun(); } try { // write out all the parent files for (ParentFile pf : msRun.getParentFiles()) { xmlw.writeEmptyElement("parentFile"); writeNonNull(xmlw, "fileName", pf.getFileName()); writeNonNull(xmlw, "fileType", pf.getFileType()); writeNonNull(xmlw, "fileSha1", pf.getFileSHA()); } // write out all the msInstrument information MsInstrument msInstrument = msRun.getMsInstrument(); if (msInstrument != null) { xmlw.writeStartElement("msInstrument"); // write out msManufacture if (msInstrument.getMsManufacturer() != null) { xmlw.writeEmptyElement("msManufacturer"); writeNonNull(xmlw, "category", msInstrument.getMsManufacturer().getCategory()); if (msInstrument.getMsManufacturer().getValue() != null) writeNonNull(xmlw, "value", msInstrument.getMsManufacturer().getValue()); } // write out msModel if (msInstrument.getMsModel() != null) { xmlw.writeEmptyElement("msModel"); writeNonNull(xmlw, "category", msInstrument.getMsModel().getCategory()); writeNonNull(xmlw, "value", msInstrument.getMsModel().getValue()); } // write out msManufacture if (msInstrument.getMsIonisation() != null) { xmlw.writeEmptyElement("msIonisation"); writeNonNull(xmlw, "category", msInstrument.getMsIonisation().getCategory()); writeNonNull(xmlw, "value", msInstrument.getMsIonisation().getValue()); } // write out msManufacture if (msInstrument.getMsMassAnalyzer() != null) { xmlw.writeEmptyElement("msMassAnalyzer"); writeNonNull(xmlw, "category", msInstrument.getMsMassAnalyzer().getCategory()); writeNonNull(xmlw, "value", msInstrument.getMsMassAnalyzer().getValue()); } // write out msManufacture if (msInstrument.getMsDetector() != null) { xmlw.writeEmptyElement("msDetector"); writeNonNull(xmlw, "category", msInstrument.getMsDetector().getCategory()); writeNonNull(xmlw, "value", msInstrument.getMsDetector().getValue()); } // write out software if (msInstrument.getSoftware() != null) { xmlw.writeEmptyElement("software"); writeNonNull(xmlw, "type", msInstrument.getSoftware().getType()); writeNonNull(xmlw, "name", msInstrument.getSoftware().getName()); writeNonNull(xmlw, "version", msInstrument.getSoftware().getVersion()); writeNonNull(xmlw, "completionTime", msInstrument.getSoftware().getCompletionTime()); } // write out msResolution if (msInstrument.getMsResolution() != null) { xmlw.writeEmptyElement("msResolution"); writeNonNull(xmlw, "category", msInstrument.getMsResolution().getCategory()); writeNonNull(xmlw, "value", msInstrument.getMsResolution().getValue()); } // write out operator if (msInstrument.getOperator() != null) { xmlw.writeEmptyElement("operator"); writeNonNull(xmlw, "first", msInstrument.getOperator().getFirst()); writeNonNull(xmlw, "last", msInstrument.getOperator().getLast()); writeNonNull(xmlw, "email", msInstrument.getOperator().getEmail()); writeNonNull(xmlw, "phone", msInstrument.getOperator().getPhone()); writeNonNull(xmlw, "URI", msInstrument.getOperator().getURI()); } xmlw.writeEndElement(); } // write out all the dataProcessing information for (DataProcessing dp : msRun.getDataProcessings()) { xmlw.writeStartElement("dataProcessing"); writeNonNull(xmlw, "intensityCutoff", dp.getIntensityCutoff()); writeNonNull(xmlw, "centroided", dp.getCentroided()); writeNonNull(xmlw, "deisotoped", dp.getDeisotoped()); writeNonNull(xmlw, "chargeDeconvoluted", dp.getChargeDeconvoluted()); writeNonNull(xmlw, "spotIntegration", dp.getSpotIntegration()); // get all software Software software = dp.getSoftware(); // write out software if (software != null) { xmlw.writeEmptyElement("software"); writeNonNull(xmlw, "type", software.getType()); writeNonNull(xmlw, "name", software.getName()); writeNonNull(xmlw, "version", software.getVersion()); writeNonNull(xmlw, "completionTime", software.getCompletionTime()); } xmlw.writeEndElement(); } } catch (XMLStreamException e) { throw new RuntimeException("Can't write mzXML meta-data!", e); } }
/** * Main program. Expects three arguments:<br> * <code> <feature_file.xml> <product_name> <person-days-available></code><br> * Any errors result in an error message and a usage message to stderr and termination with an * exit code of -1. Correct execution will result in an exit code of 0. */ public static void main(String[] argv) { // get data from test scaffolding // The real XML file reader is being worked on now. FileInput reader = new TestInput(); // check for correct number of arguments if (argv.length != 3) dieUsage("wrong number of arguments"); // check for non-null filename String filename = argv[0]; if (filename == null || filename.equals("")) dieUsage("empty filename specified"); // check for non-null osftware product String software = argv[1]; if (software == null || software.equals("")) dieUsage("empty software name specified"); // parse capacity, checking for errors String capacityStr = argv[2]; double capacity = 0.0; try { capacity = Double.parseDouble(capacityStr); } catch (NumberFormatException e) { dieUsage("Illegal capacity specified, '" + capacityStr + "'"); } if (capacity <= 0) dieUsage("Capacity specified, '" + capacityStr + "' must be be greater than 0"); // read the XML feature file. Returns the root "Company" object from the file. Company c = null; try { c = reader.readFile(filename); } catch (java.io.FileNotFoundException e) { dieUsage("File not found, '" + filename + "'"); } catch (java.io.IOException e) { dieUsage("IO error while opening file '" + filename + "'"); } // check that software product specified on the command line exists in the file Software s = c.getSoftware(software); if (s == null) dieUsage("Specified software product not found, '" + software + "'"); // plan a release given the capacity in person-days specified on the command line Release planned = s.planRelease(capacity); planned.setDesignator("in-plan"); // plan a second release given the extra capacity and subtract the features from // the above rleease, leaving just the excess. Release overflow = s.planRelease(capacity * JUST_MISSED_RATIO); overflow.subtract(planned); overflow.setDesignator("just-missed"); // write the report header, echoing the comamnd line Report.writeHeader( "File: " + filename + " Product: " + software + " Capacity: " + capacityStr); // write a summary chart for all the features, the in-plan features, and the just-missed // features final FeatureList[] featureListsToSummarize = {s, planned, overflow}; Report.writeSummaryTable(featureListsToSummarize); // write details for the in-plan features Report.writeFeatures("In-Plan Features for sizing " + capacityStr, planned); // write details for the just-missed features Report.writeFeatures( "Just-Missed Features under sizing " + capacity * JUST_MISSED_RATIO, overflow); // all went well System.exit(0); }