Currently the company uses a paper?based system. Here is how it works. Every tim
ID: 3644891 • Letter: C
Question
Currently the company uses a paper?based system. Here is how it works.Every time a call is received for a pickup, a slip of paper is filled out, including the item to be picked up (package, letter, tube, etc.), the place the pickup is to be made, and the place the item is to be dropped off. The slip is then pinned to a bulletin board next to a number that shows its priority. During the course of a working day these slips of papers are moved around on the board. When a delivery is completed, the slip must be removed and all pending pickups below it must be moved up. Occasionally a customer will request an immediate pickup, so that slip must be placed on the board between other pickups and again the slips are rearranged. Occasionally a customer will call to cancel a pickup, so the corresponding slip must be removed from the board and all slips below it moved up a position.
The data is stored in datafile.txt.
Delivery Services Application needs to function similarly to the paper?based system so that the dispatcher can learn to use it quickly. The dispatcher must be able to do the following:
1. Add a new delivery slip, including entering the necessary delivery information (item, source, and destination) and place it into the list at any position.
2. Move a delivery slip to a new position in the list.
3. Delete a delivery slip.
4. View the list of slips.
The client is estimating that there will not own more than 100 delivery slips.
TO DO:
A. UML Modeling for Requirements Specifications is DESIRED!
B. Implement the application in C. (Separating into modules is DESIRED!)
(FILE I/O is REQUIRED!)
datafile.txt
123 Soth Market Street
Downtown 101
Package
0
1599 Burbank Road
Cinama 10
Movie posters in tubes
1
Explanation / Answer
import java.net.*; import javax.help.*; import javax.swing.*; import java.awt.event.*; public class HelpMenu { JFrame f; JMenuItem topics; public HelpMenu() { f = new JFrame("Menu Example"); JMenuBar mbar = new JMenuBar(); // a file menu JMenu file = new JMenu("File"); JMenu help = new JMenu("Help"); // add an item to the help menu help.add(topics = new JMenuItem("Help Topics")); // add the menu items to the menu bar mbar.add(file); mbar.add(help); // 1. create HelpSet and HelpBroker objects HelpSet hs = getHelpSet("sample.hs"); HelpBroker hb = hs.createHelpBroker(); // 2. assign help to components CSH.setHelpIDString(topics, "top"); // 3. handle events topics.addActionListener(new CSH.DisplayHelpFromSource(hb)); // attach menubar to frame, set its size, and make it visible f.setJMenuBar(mbar); f.setSize(500, 300); f.setVisible(true); } /** * find the helpset file and create a HelpSet object */ public HelpSet getHelpSet(String helpsetfile) { HelpSet hs = null; ClassLoader cl = this.getClass().getClassLoader(); try { URL hsURL = HelpSet.findHelpSet(cl, helpsetfile); hs = new HelpSet(null, hsURL); } catch(Exception ee) { System.out.println("HelpSet: "+ee.getMessage()); System.out.println("HelpSet: "+ helpsetfile + " not found"); } return hs; } public static void main(String argv[]) { new HelpMenu(); } } class book { public: typedef set setOfEntry; typedef setOfEntry::iterator iterator; void add(ObjVar aEntry); void remove(ObjVar aEntry); ObjVar find(string aName) const // more interface... private: setOfEntry entries; }; ... void book::add(ObjVar aEntry) { entries.insert(aEntry); } void book::remove(ObjVar aEntry) { entries.erase(aEntry); } ObjVar book::find(string aName) const { // entry equality defined as equal names ObjVartemp(new entry(aName, "","","")); ObjVar null; iterator p = entries.find(temp); return p == entries.end() ? null : *p ; } Removal of an entry (in book::remove()) does not need to explicitly delete the entry: it will still be referenced, after all, by the caller in code such as the following: extern book& theBook(); // singleton book extern ui& theUi(); // singleton ui ... void removeNameHandler() { string s = theUi().prompt("Name to remove"); ObjVar e = theBook().find(s); if (!e.isNull) theBook().remove(e); else theUi().alert(s + " not found"); } The ObjVar object variable referencing the entry to remove goes out of scope at the end of this function - assuming no other object variables reference the selected entry, it is only at this point that the underlying entry object is deleted.Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.