intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Java Programming for absolute beginner- P28

Chia sẻ: Cong Thanh | Ngày: | Loại File: PDF | Số trang:6

53
lượt xem
4
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Java Programming for absolute beginner- P28:Hello and welcome to Java Programming for the Absolute Beginner. You probably already have a good understanding of how to use your computer. These days it’s hard to find someone who doesn’t, given the importance of computers in today’s world. Learning to control your computer intimately is what will separate you from the pack! By reading this book, you learn how to accomplish just that through the magic of programming.

Chủ đề:
Lưu

Nội dung Text: Java Programming for absolute beginner- P28

  1. JavaProgAbsBeg-90Index.qxd 2/25/03 8:59 AM Page 498 498 L Racer program example code, 95–96 Label class, 183–185 skipping values, 98–99 Index labels, 175 while, 108–110 layout managers BorderLayout, 227–229 M CardLayout, 238–242 MadLib game, 172–173 FlowLayout, 223–226 AdvancedMadLip application, creating, GridBagLayout, 229–236 271–275 GridLayout, 225–228 game frame, creating, 217–219 overview, 223 MadDialog component, creating, 214–218 lightweight components, 431 MadInputPanel class, creating, 268–272 creating, 432–433 main() method jpr.lightweight package, creating command-line arguments and, 46–47 documentation for, 450–453 function of, 19 JPRButton3D class, 447–451 Math class, 57 JPRButton3D class, testing, 451–454 methods, list of, 63 JPRComponent3D class, source code, mathematical operations. See also 437–443, 447–448 numbers, 37 JPRRectComponent3D class, 444–447 counting backwards, 101–103 lines, drawing, 315–316 floating point math, list of, 37 Linux, installing SDK on, 10–11 integer math, list of, 37 List component (AWT), 176, 195–198 modulus operators, 35–36 list() method, 124 operator precedence, 37 literals percentages, 34–35 case sensitivity, 28–29 Math.random() method, 58 character escape codes, 29–31 Menu component (AWT), 203–207 defined, 28–29 method access modifiers, 144–145 local variables, 126–127 methods logical compliment operators, 69–70 block statements, 16 loops BoderLayout(), 228–229 arrays, looping on, 104–106 boolean isEnabled(), 173–174 break statement, 112–116 boolean isFocusTraversable(), 173–174 defined, 94–96 boolean isLightWeigth(), 173–174 do, 109–111 brighter(), 337–338 endless, 112 buttons, list of, 184–187 exception handling, 115–117 CodeBase(), 302–303 infinite, 112 constructor, 140–142 for loop, 96 createStory(), 272–273 counting backwards, 101–103 darker(), 337–338 nested, 102–105 declaring, 136–137 TEAM LinG - Live, Informative, Non-cost and Genuine! Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
  2. JavaProgAbsBeg-90Index.qxd 2/25/03 8:59 AM Page 499 499 defined, 16 next(), 268–269 defining, 132–136 notify(), 361–362 Index destroy(), 290–292 notifyAll(), 361–362 dispose(), 181–182, 244 overriding, 157–158 drawImage(), 332–333 paint(), 23 drive(), 435–436 passing parameters, 136–139 getAppletInfo(), 281, 285–286 play(), 167, 370 getBackgound(), 173–174 previous(), 268–269 getBounds(), 173–174 randomize(), 348–349 getFont(), 173–174 readParams(), 309 getFontMetrics(), 327–328 repaint(), 344–345 getHeight(), 173–174, 334–335 reset(), 152, 158–159 getID(), 455 revealAll(), 468–469 getImage(), 333–334 rotateClockwise(), 380 getInteriorSize(), 447–448 rotateCounterClockwise(), 380 getItem(), 257–258 run(), 356, 358 getKeyCode(), 267 setColor(), 136 getParameter(), 284–285 setFont(), 326–327 getParameterInfo(), 285–286 setSeed(), 61 getPreferredSize(), 173–174 shuffle(), 158–159 getSize(), 173–174 start(), 290–292, 356 getSource(), 244, 465–466 static methods, 140–141 getStateChange(), 257–258 stop(), 290–292 getStringArray(), 268–269 toString(), 157–158 getUserInput(), 167 update(), 363–364 getWidth(), 173–174, 334–335 values, returning, 139–140 getX(), 173–174 wait(), 361–362 getY(), 173–174 Mine Cell GridLayout(), 227–228 MineCell class init(), 280, 290–292 importing, 456–457 Integer.parseInt(), 44–45 MineCell.java, source code listing, interrupt(), 361–362 458–462 list(), 124 MouseEvent pass, 457–458 main() testing, 462–463 command-line arguments and, 46–47 MineCellEvent class, 455–456 function of, 19 MineCellListener interface, 456 Math Class, 63 MineField class Math.random(), 58 checkIfSolved() method, 469 method overloading, 138–140 getSource() method, 465–466 method signature, 136 members, declaring, 465–466 TEAM LinG - Live, Informative, Non-cost and Genuine! Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
  3. JavaProgAbsBeg-90Index.qxd 2/25/03 8:59 AM Page 500 500 MineCell.EMPTY, source code, Math.random() method, 58 467–468 methods, list of, 58 Index MineField. java, source code listing, NumberMaker application sample, 57 470–474 pseudorandom numbers, 59–60 randomizeField() method, 466–467 setSeed() method, 61 revealAll() method, 468–469 values, getting larger than 1, 65 MineFieldEvent class, 464–465 values, skipping, 98–99 MineFieldListener interface, 464–465 numerical comparison operators, 68–69 MinePatrol application, source code listing, 474–476 O modifiers, access modifiers, 144–145 object-oriented programming (OOP) modulus operators, 35–37 encapsulation, 146–148 MouseEvents class, 261–265 inheritance, 154 multi-line comments, 18 polymorphism, 157–158 multidimensional arrays, 87–89 OOP. See object-oriented programming multiplication operator (*), 37 operators boolean logical, 70–72 N conditional, 68–69 naming variables, 31–32 increment, 96–97 nested classes, 398–399 compound assignment, 99–100 nested if-else statements, 77–79 postfix, 96–97 nested loops, 102–105 prefix, 96–97 next() method, 268–269 integer bitwise, 71–72 notify() method, 361–362 logical compliment, 69–70 notifyAll() method, 361–362 numerical comparison, 68–69 numbers. See also mathematical operations operator precedence, 37 floating-point, 34–35 ternary, 72–73 operator precedence, 37 outer classes, 398–399 parsing strings to, 44–45 ovals, drawing, 321–322 random numbers overriding methods, 157–158 AmIRandom program, 59–60 DiceRoller application example, 65–67 P double, assigning, 57–58 packages even numbers only, 66–68 declaring, 434–435 if statement, 66–68 defined, 40 MakerUtil application example, 58–59 paint() method, 23 Math Class method, list of, 63 Panel component (AWT), 208–209 MathClassTest application example, parameters, passing parameters, 136–139 62–64 parsing strings to numbers, 44–45 TEAM LinG - Live, Informative, Non-cost and Genuine! Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
  4. JavaProgAbsBeg-90Index.qxd 2/25/03 8:59 AM Page 501 501 passing parameters, 136–139 Random class pausing threads, 361–362 MakerUtil application, source code Index percentages, calculating, 34–35 example, 58–59 platform independence, 4–5 methods, list of, 58 play() method, 167, 370 setSeed() method, 61 polygons, drawing, 323–326 values, getting larger than 1, 65 polymorphism, 157–158 randomize() method, 348–349 PopupMenu component (AWT), 206–208 readParams() method, 309 postfix increment operators, 96–97 rectangles, drawing, 317–320 prefix increment operators, 96–97 repaint() method, 344–345 previous() method, 268–269 reset() method, 152, 158–159 Prima Tech Web site, 477 returning values, 139–140 primitive data types, 27 revealAll() method, 468–469 printing status messages, 293 rotateClockwise() method, 380 private variables, 144–145 rotateCounterClockwise() method, 380 procedure-oriented program, 5 run() method, 356, 358 programming languages, 4 programs S defined, 4 sample codes. See also example codes examples of. See example codes Hello, World application sample procedure-oriented, 5 compiling, 12–14 protected keyword, 144–145 running, 14–15 pseudorandom numbers, 59–60 source code, 12–13 public keyword, 16 HelloWeb applet, 2–3 NumberMaker application, source code, R 57 random numbers Scrollbar component (AWT), 176, 209–213 AmIRandom program, 59–60 security DiceRoller application example, 65–67 applets, 290–291 double, assigning, 57–58 thread-safe code, 360–361 even numbers only, 66–68 sentinel values, 101 if statement, 66–68 setColor() method, 136 Math Class method, list of, 63 setFont() method, 326–327 MathClassTest application example, 64 setSeed() method, 61 Math.random() method, 58 shuffle() method, 158–159 NumberMaker application source code single-line comments, 18 sample, 57 skipping values, 98–99 pseudorandom numbers, 59–60 Solaris, installing SDK on, 10 TEAM LinG - Live, Informative, Non-cost and Genuine! Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
  5. JavaProgAbsBeg-90Index.qxd 2/25/03 8:59 AM Page 502 502 sound files super classes, 22 applets and, 302–304 switch statement, 80–82 Index playing from applications, 369–370 case values, 82 SoundApplication, source code, 369–370 compile-time errors, 82 source code. See example codes FuzzyDice program example, 83–84 Sprite class synchronized keyword, 360–361 overview, 363–364 syntax, 15 testing, 365–367 start() method, 290–292, 356 T statements tags, javadoc, 436–437 block statements, 16, 67–68 ternary operators, 72–73 break statement, loops and, 112–116 TextArea component (AWT), 176, 190–191, conditional statements, 66–67 192–193 if-else, 74, 75–76 TextEvents class, 260–262 flowchart, 74–75 TextField (AWT), 176 indentation, 80–81 TextField class, 186–191 ManyTemps program example, 79–80 this keyword, 143 syntax convention, 80–81 threads import, 22 creating switch, 80–82 using Runnable interface, 358–359 case values, 82 using Thread class, 356–357 compile-time errors, 82 defined, 354 FuzzyDice program example, 83–84 interrupt() method, 361–362 static methods, 140–141 multithreading, problems associated static variables, 127–129 with, 358–361 status messages, printing, 293 notify() method, 361–362 stop() method, 290–292 notifyall() method, 361–362 strings output, order of, 355 concatenation, 48–49 pausing, 361–362 defined, 48 thread-safe code, 360–361 drawing, 325–327 wait() method, 361–362 index of, 48–49 toString() method, 157–158 methods, list of, 49–50 try-catch block, exception handling and, parsing to numbers, 44–45 116–117 String class, 48 String objects, 48–49 U substrings, 48 underscore (_), 31 subclasses, 22 Unicode, 27 subtraction operator (-), 37 update() method, 363–364 TEAM LinG - Live, Informative, Non-cost and Genuine! Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
  6. JavaProgAbsBeg-90Index.qxd 2/25/03 8:59 AM Page 503 503 user input W BufferedReader class, 40–42 wait() method, 361–362 Index example code, 38–39 Web pages, including applets in, 282–284 InputStreamReader class, 40 applet HTML tag, 284–285 passing parameters to applets, 284–288 V security restrictions, 290–291 values using frames with, 288–290 assigning while loop, 108–110 to arrays, 85–88 WindowListener interface, 242–245 to variables, 31–34 Windows Update Web site, 279 returning, 139–140 Windows (Win32) installation, installing sentinel, 101 SDK on, 8–10 variables assigning values to, 31–34 class, 126–127 declaring, 31–32 defined, 26–27 instance, 126–127 local, 126–127 naming, 31–32 private, 144–145 static, 127–129 Vector class, 160–163 TEAM LinG - Live, Informative, Non-cost and Genuine! Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2