« Home « Chủ đề lập trình website

Chủ đề : lập trình website


Có 80+ tài liệu thuộc chủ đề "lập trình website"

Java Programming for absolute beginner- P3

tailieu.vn

If you just want to make a note about a par- ticular line of code, you usually precede that line of code with a single-line com- ment as shown here:. //The following line of code prints a message using standard output System.out.println("Hello, World!");. After the double slashes, you can type anything you want to on that single line and the...

Java Programming for absolute beginner- P4

tailieu.vn

//The addition happens first because of the parentheses //Next the division and then the subtraction.. System.out.println . Any- time the user runs the application, he or she can enter different input, causing the program to have the capability to have different output each time it is run.. What follows is a listing of the HelloUser application:. reader = new BufferedReader(new...

Java Programming for absolute beginner- P5

tailieu.vn

by the Math.random(). The java.util.Random Class. Uses java.util.Random to generate random numbers. import java.util.Random;. System.out.println(“Random Integers:”);. System.out.println(rand.nextInt. System.out.println(“\nRandom Integers between 0 and 10:”);. System.out.println(rand.nextInt(iLimit. System.out.println(“\nRandom Floats:”);. System.out.println(rand.nextFloat. System.out.println(“\nRandom Booleans:”);. System.out.println(rand.nextBoolean. The output of the NumberMakerUtil program is displayed in Figure 3.3.. This is the output of the NumberMakerUtil. This makes rand an instance of the Random class and you use...

Java Programming for absolute beginner- P6

tailieu.vn

System.out.println(name. This is several runs of the HighOrLowTemp. The ManyTemps program demonstrates the use of the nested if-else structure. It prints a different message depending on the range of the randomly generated temperature.. System.out.println(“The temperature is. System.out.println(“It’s DANGEROUSLY FREEZING! Stay home.”);. System.out.println(“It’s extremely cold! Bundle up tight.”);. System.out.println(“It’s cold enough to snow.”);. System.out.println(“You should bring a coat.”);. System.out.println(“It’s nice and...

Java Programming for absolute beginner- P7

tailieu.vn

System.out.print(i. System.out.println(“y and x both = 0”);. System.out.println(“The expression y = x. System.out.println(“a and b both = 0”);. System.out.println(“The expression b = ++a. Note that the variable y is assigned the value 0 , which is the value of x before it is incremented because that is the value of the postfix increment expression. On the other hand, the value...

Java Programming for absolute beginner- P9

tailieu.vn

System.out.println(“Your number is. reader = new BufferedReader(new InputStreamReader(System.in));. System.out.println(“I’m thinking of a number between 1 and 100.”);. System.out.println(“Can you guess what it is?”);. System.out.print(“Your guess:. System.out.println(“That is not a valid Integer!”);. System.out.println(“You guessed my number in. System.out.println(“My number is HIGHER.”);. System.out.println(“My number is LOWER.”);. System.out.println(“Remember, my number is between. You set it out of the range of possible numbers, so...

Java Programming for absolute beginner- P10

tailieu.vn

System.out.println(tt.x);. You can see that it does the same thing as in the previous example. It adds up two vari- ables’ values and stores the result in the first variable.. It’s the same concept here, you tell the method where your object is and then it goes and operates on it, and when it’s done, your object might have changed.....

Java Programming for absolute beginner- P11

tailieu.vn

First you used what you learned about the super keyword to call Automobile ’s version of the method, and then you simply appended the trailer value.. Back to the BlackJack Game. You also learn about the java.util.Vector class, which will help in creating the final game. To do this, you import the java.util.Random class. import java.util.Random;. It is initialized to...

Java Programming for absolute beginner- P12

tailieu.vn

Table 6.2 summarizes some of the Frame class’s methods.. import java.awt.Frame;. Then you declare the UselessFrame class and indicate that it is a subclass of the Frame class:. Image getIconImage() Returns this Frame ’s icon Image object.. MenuBar getMenuBar() Returns this Frame ’s MenuBar . String getTitle() Returns this Frame ’s String title.. setIconImage(Image) Sets the Frame ’s icon image...

Java Programming for absolute beginner- P13

tailieu.vn

l4.add(“Not Enabled”);. l4.add(“Nope”);. frame.add(l1);. frame.add(l2);. frame.add(l3);. frame.add(l4);. frame.add(cb1);. frame.add(cb2);. frame.add(cb3);. frame.add(cb4);. frame.add(cb5);. frame.add(cb6);. frame.add(cb7);. frame.add(cb8);. frame.add(c1);. frame.add(c2);. frame.add(c3);. frame.add(c4);. myMenu.add(myItem);. myBar.add(myMenu);. fileMenu.add(fm_open);. fileMenu.add(fm_save);. fileMenu.add(fm_saveAs);. fileMenu.add(fm_exit);. editMenu.add(em_options);. menuBar.add(editMenu);. popMenu.add(pm_copy);. popMenu.add(pm_paste);. popMenu.add(pm_delete);. frame.add(popMenu);. myPanel.add(someComponent);. p1.add(new Label(“URL. p1.add(new TextField(25));. p1.add(new Button(“Go”));. p2.add(new Label(“Pick one:”));. p2.add(new Checkbox(“Drums”, false, cbg));. p2.add(new Button(“OK”));. frame.add(p1);. frame.add(p2);. ctf.add(sbt1);. ctf.add(sbt2);. nPanel.add(new Label(“Nouns:”));. nPanel.add(n1). nPanel.add(n2). nPanel.add(n3);. aPanel.add(new Label(“Adjectives:”));. aPanel.add(a1). aPanel.add(a2)....

Java Programming for absolute beginner- P14

tailieu.vn

The buildStory() method itself works by creating an array of String s that rep- resent segments of the story that break where words should be inserted. Go back and try playing around with some of the methods that appeared in tables of this chapter, but never actually made it into any of the programs to see how their effects look.....

Java Programming for absolute beginner- P15

tailieu.vn

which returns a Dimension object representing the resolution of the computer screen, whether it is 640 by 480, 800 by 600, or what- ever. The Toolkit class is the abstract subclass of all implementations of the AWT, the default of which is different depending on what operating system you are running. To center the GUIFrame on screen I needed to...

Java Programming for absolute beginner- P16

tailieu.vn

The program then obtains the value of the item depend- ing on what type of component it is. because e.getItem() returns the Integer index of the List item that was either selected or deselected. I had to explicitly cast it to an Integer object and call its intValue() method, which returns an int type value of the Integer object. Then...

Java Programming for absolute beginner- P17

tailieu.vn

The applet is driven by parameters set within the HTML. None of the ques- tions are hard coded in the applet itself. The questions are specified within the HTML parameters, which enable you to ask any number of questions by modify- ing the HTML file and without having to rewrite or recompile the applet code.. If you experience any difficulty...

Java Programming for absolute beginner- P18

tailieu.vn

v.addElement(nFields[3].getText. v.addElement(vFields[3].getText());. v.addElement(oFields[1].getText. v.addElement(nFields[4].getText());. v.addElement(nFields[5].getText. v.addElement(nFields[6].getText());. v.addElement(vFields[7].getText. v.addElement(nFields[7].getText());. v.addElement(vFields[3].getText. v.addElement(oFields[1].getText());. v.addElement(vFields[0].getText. v.addElement(vFields[0].getText());. v.addElement(oFields[0].getText());. v.addElement(vFields[1].getText. v.addElement(oFields[2].getText());. v.addElement(nFields[0].getText. v.addElement(oFields[0].getText. v.addElement(vFields[2].getText());. v.addElement(oFields[5].getText. v.addElement(vFields[4].getText());. v.addElement(vFields[4].getText. v.addElement(oFields[6].getText());. When you are writing an applet, it is best to refrain from using the newest Java features, because browser support for the newest releases always comes later than the release dates of the Java API. This section describes...

Java Programming for absolute beginner- P19

tailieu.vn

and then fill a rectangle of the same size over it in a different color, you would still see the right and bottom edges of the drawn rectangle because it is one pixel wider and taller. This same idea holds true for all draw and fill methods of the Graphics class. FIGURE 9.3 Drawing rectangles. is the coolest.. Here is...

Java Programming for absolute beginner- P20

tailieu.vn

Demonstrates the Color class. Color(int r, int g, int b, int a) Constructs a Color object with the given red, green, blue, and alpha values, which range from 0-255.. controlPanel.add(bright);. controlPanel.add(dark);. Calling darker() on a Color object and reassigning its value a certain number of times and then subsequently calling brighter() the same number of times will not necessarily result...

Java Programming for absolute beginner- P21

tailieu.vn

Here is a listing of the source code:. public void run(). //start the thread t.start();. You can see the output of the RunnableTest application in Figure 10.3.. What’s the difference between extending Thread and implementing Runnable ? Why would you choose one over the other? Generally, it is better to implement the Runnable interface. FIGURE 10.3. The output of the...

Java Programming for absolute beginner- P22

tailieu.vn

The Project: The Block Game. The Block Game is similar in concept to the well-known Tetris game, owned by the Tetris Company, and originally developed by Alexey Pajitnov. The Block Game project in this book is for learning purposes only and can’t truly compare to the actual Tetris game.. Building the Block Class. The blocks that fall into the play...

Java Programming for absolute beginner- P23

tailieu.vn

The registering of PlayAreaListener s takes place in the PlayArea class. The PlayArea class also provides two methods for updating this Vector object, addPlayAreaListener(PlayAreaListener) and removePlayAreaListener(Pla- yAreaListener. You fire PlayAreaEvent s from the PlayArea class by creating an instance of the PlayAreaEvent class and then calling the registered PlayAreaListener s’ block- Landed(BlockEvent) methods. The PlayArea class has a private method...