Java Reference
In-Depth Information
Step 5 If you use a tree, decide whether to supply a comparator.
Look at the class of the elements or keys that the tree manages. Does that class
implement the Comparable interface? If so, is the sort order given by the
compareTo method the one you want? If yes, then you don't need to do anything
further. If no, then you must define a class that implements the Comparator
interface and define the compare method. Supply an object of the comparator
class to the TreeSet or TreeMap constructor.
R ANDOM F ACT 16.2: Software Piracy
As you read this, you have written a few computer programs, and you have
experienced firsthand how much effort it takes to write even the humblest of
programs. Writing a real software product, such as a financial application or a
computer game, takes a lot of time and money. Few people, and fewer companies,
are going to spend that kind of time and money if they don't have a reasonable
chance to make more money from their effort. (Actually, some companies give
away their software in the hope that users will upgrade to more elaborate paid
versions. Other companies give away the software that enables users to read and
use files but sell the software needed to create those files. Finally, there are
individuals who donate their time, out of enthusiasm, and produce programs that
you can copy freely.)
When selling software, a company must rely on the honesty of its customers. It is
an easy matter for an unscrupulous person to make copies of computer programs
without paying for them. In most countries that is illegal. Most governments
provide legal protection, such as copyright laws and patents, to encourage the
development of new products. Countries that tolerate widespread piracy have
found that they have an ample cheap supply of foreign software, but no local
manufacturers willing to design good software for their own citizens, such as word
processors in the local script or financial programs adapted to the local tax laws.
When a mass market for software first appeared, vendors were enraged by the
money they lost through piracy. They tried to fight back by various schemes to
ensure that only the legitimate owner could use the software. Some manufacturers
used key disks: disks with special patterns of holes burned in by a laser, which
738
Search WWH ::




Custom Search