Как сделать звук на всю 2003 |
Языки программирования | ||
<< Новые возможности Java 5 | Программирование кнопок в Delphi 7 >> |
Автор: kalid. Чтобы познакомиться с картинкой полного размера, нажмите на её эскиз. Чтобы можно было использовать все картинки для урока информатики, скачайте бесплатно презентацию «Как сделать звук на всю 2003.ppt» со всеми картинками в zip-архиве размером 396 КБ.
Сл | Текст | Сл | Текст |
1 | Chapter 3 - Introduction to Java | 25 | </html> |
Applets. Outline 3.1 Introduction 3.2 | 26 | 3.4 Drawing Strings and Lines. Method | |
Sample Applets from the Java 2 Software | drawLine of class Graphics Takes as | ||
Development Kit 3.3 Simple Java Applet: | arguments Graphics object and line’s end | ||
Drawing a String 3.4 Drawing Strings and | points X and y coordinate of first | ||
Lines 3.5 Adding Floating-Point Numbers | endpoint X and y coordinate of second | ||
3.6 Java Applet Internet and World Wide | endpoint. 26. | ||
Web Resources 3.7 (Optional Case Study) | 27 | 3.5 Adding Floating-Point Numbers. | |
Thinking About Objects: Identifying the | Next applet Mimics application for adding | ||
Classes in a Problem Statement. 1. | two integers (Fig 2.9) This time, use | ||
2 | 3.1 Introduction. Applet Program that | floating point numbers (numbers with a | |
runs in appletviewer (test utility for | decimal point) Using primitive types | ||
applets) Web browser (IE, Communicator) | double – double precision floating-point | ||
Executes when HTML (Hypertext Markup | numbers float – single precision | ||
Language) document containing applet is | floating-point numbers Show program, then | ||
opened and downloaded Applications run in | discuss. 27. | ||
command windows Notes Mimic several | 28 | AdditionApplet.java 1. import 2. Class | |
features of Chapter 2 to reinforce them | AdditionApplet (extends JApplet) 3. Fields | ||
Focus on fundamental programming concepts | 4. init 4.1 Declare variables 4.2 | ||
first Explanations will come later. 2. | showInputDialog 4.3 parseDouble. 28. 1 // | ||
3 | 3.2 Sample Applets from the Java 2 | Fig. 3.13: AdditionApplet.java 2 // Adding | |
Software Development Kit. Sample Applets | two floating-point numbers. 3 4 // Java | ||
Provided in Java 2 Software Development | packages 5 import java.awt.Graphics; // | ||
Kit (J2SDK) Source code included (.java | import class Graphics 6 import | ||
files) Study and mimic source code to | javax.swing.*; // import package | ||
learn new features All programmers begin | javax.swing 7 8 public class | ||
by mimicking existing programs Located in | AdditionApplet extends JApplet { 9 double | ||
demo directory of J2SDK install Can | sum; // sum of values entered by user 10 | ||
download demos and J2SDK from | 11 // initialize applet by obtaining | ||
java.sun.com/j2se/1.4.1/. 3. | values from user 12 public void init() 13 | ||
4 | 3.2 Sample Applets from the Java 2 | { 14 String firstNumber; // first string | |
Software Development Kit. Running applets | entered by user 15 String secondNumber; // | ||
In command prompt, change to demo | second string entered by user 16 17 double | ||
subdirectory of applet cd | number1; // first number to add 18 double | ||
c:\j2sdk1.4.1\demo\applets cd | number2; // second number to add 19 20 // | ||
appletDirectoryName There will be an HTML | obtain first number from user 21 | ||
file used to execute applet Type | firstNumber = JOptionPane.showInputDialog( | ||
appletviewer example1.html appletviewer | 22 "Enter first floating-point | ||
loads the html file specified as its | value" ); 23 24 // obtain second | ||
command-line argument From the HTML file, | number from user 25 secondNumber = | ||
determines which applet to load (more | JOptionPane.showInputDialog( 26 | ||
section 3.3) Applet will run, Reload and | "Enter second floating-point | ||
Quit commands under Applet menu. 4. | value" ); 27 28 // convert numbers | ||
5 | 3.2 Sample Applets from the Java 2 | from type String to type double 29 number1 | |
Software Development Kit. You start as | = Double.parseDouble( firstNumber ); 30 | ||
player "X" Fig. 3.2 Sample | number2 = Double.parseDouble( secondNumber | ||
execution of applet TicTacToe. 5. | ); 31. | ||
6 | 3.2 Sample Applets from the Java 2 | 29 | 5. Draw applet contents 5.1 Draw a |
Software Development Kit. Fig. 3.4 Sample | rectangle 5.2 Draw the results HTML file. | ||
execution of applet DrawTest. Drag the | 29. 32 // add numbers 33 sum = number1 + | ||
mouse pointer in the white area to draw. | number2; 34 35 } // end method init 36 37 | ||
Select the shape to draw by clicking the | // draw results in a rectangle on applet’s | ||
down arrow, then clicking Lines or Points. | background 38 public void paint( Graphics | ||
This GUI component is commonly known as a | g ) 39 { 40 // call superclass version of | ||
combo box, choice or drop-down list. | method paint 41 super.paint( g ); 42 43 // | ||
Select the drawing color by clicking the | draw rectangle starting from (15, 10) that | ||
circle for the color you want. These GUI | is 270 44 // pixels wide and 20 pixels | ||
components are commonly known as radio | tall 45 g.drawRect( 15, 10, 270, 20 ); 46 | ||
buttons. 6. | 47 // draw results as a String at (25, 25) | ||
7 | 3.2 Sample Applets from the Java 2 | 48 g.drawString( "The sum is " + | |
Software Development Kit. Demonstrates 2D | sum, 25, 25 ); 49 50 } // end method paint | ||
drawing capabilities built into Java2. Try | 51 52 } // end class AdditionApplet. 1 | ||
changing the options to see their effect | <html> 2 <applet code = | ||
on the demonstration. Click a tab to | "AdditionApplet.class" width = | ||
select a two-dimensional graphics demo. 7. | "300" height = | ||
8 | 3.3 Simple Java Applet: Drawing a | "65"> 3 </applet> 4 | |
String. Now, create applets of our own | </html> | ||
Take a while before we can write applets | 30 | Program Output. 30. | |
like in the demos Cover many of same | 31 | 3.5 Adding Floating-Point Numbers. | |
techniques Upcoming program Create an | Lines 1-2: Comments Line 5: imports class | ||
applet to display "Welcome to Java | Graphics import not needed if use full | ||
Programming!" Show applet and HTML | package and class name public void paint ( | ||
file, then discuss them line by line. 8. | java.awt.Graphics g ) Line 8: specify | ||
9 | Java applet Program Output. 9. | entire javax.swing package * indicates all | |
10 | 3.3 Simple Java Applet: Drawing a | classes in javax.swing are available | |
String. Comments Name of source code and | Includes JApplet and JOptionPane Use | ||
description of applet Import predefined | JOptionPane instead of | ||
classes grouped into packages import | javax.swing.JOptionPane * does not not | ||
declarations tell compiler where to locate | load all classes Compiler only loads | ||
classes used When you create applets, | classes it uses. 31. | ||
import the JApplet class (package | 32 | 3.5 Adding Floating-Point Numbers. | |
javax.swing) import the Graphics class | Begin class declaration Extend JApplet, | ||
(package java.awt) to draw graphics Can | imported from package javax.swing Field | ||
draw lines, rectangles ovals, strings of | declaration Each object of class gets own | ||
characters import specifies directory | copy of the field Declared in body of | ||
structure. 10. | class, but not inside methods Variables | ||
11 | 3.3 Simple Java Applet: Drawing a | declared in methods are local variables | |
String. Applets have at least one class | Can only be used in body of method Fields | ||
declaration (like applications) Rarely | can be used anywhere in class Have default | ||
create classes from scratch Use pieces of | value (0.0 in this case). 32. | ||
existing classes Inheritance - create new | 33 | 3.5 Adding Floating-Point Numbers. | |
classes from old ones (ch. 9) Begins class | Primitive type double Used to store | ||
declaration for class WelcomeApplet | floating point (decimal) numbers Method | ||
Keyword class then class name extends | init Normally initializes fields and | ||
followed by class name Indicates class to | applet class Guaranteed to be first method | ||
extend (JApplet) JApplet : superclass | called in applet First line must always | ||
(base class) WelcomeApplet : subclass | appear as above Returns nothing (void), | ||
(derived class) WelcomeApplet now has | takes no arguments Begins body of method | ||
methods and data of JApplet. 11. | init. 33. | ||
12 | 3.3 Simple Java Applet: Drawing a | 34 | 3.5 Adding Floating-Point Numbers. |
String. Class JApplet defined for us | Declare variables Two types of variables | ||
Someone else defined "what it means | Reference variables (called references) | ||
to be an applet" Applets require over | Refer to objects (contain location in | ||
200 methods! extends JApplet Inherit | memory) Objects defined in a class | ||
methods, do not have to declare them all | definition Can contain multiple data and | ||
Do not need to know every detail of class | methods paint receives a reference called | ||
JApplet. 12. | g to a Graphics object Reference used to | ||
13 | 3.3 Simple Java Applet: Drawing a | call methods on the Graphics object | |
String. Class WelcomeApplet is a blueprint | Primitive types (called variables) Contain | ||
appletviewer or browser creates an object | one piece of data. 34. | ||
of class WelcomeApplet Keyword public | 35 | 3.5 Adding Floating-Point Numbers. | |
required File can only have one public | Distinguishing references and variables If | ||
class public class name must be file name. | type is a class name, then reference | ||
13. | String is a class firstNumber, | ||
14 | 3.3 Simple Java Applet: Drawing a | secondNumber If type a primitive type, | |
String. Our class inherits method paint | then variable double is a primitive type | ||
from JApplet By default, paint has empty | number1, number2. 35. | ||
body Override (redefine) paint in our | 36 | 3.5 Adding Floating-Point Numbers. | |
class Methods paint, init, and start | Method JOptionPane.showInputDialog Prompts | ||
Guaranteed to be called automatically Our | user for input with string Enter value in | ||
applet gets "free" version of | text field, click OK If not of correct | ||
these by inheriting from JApplet Free | type, error occurs In Chapter 15 learn how | ||
versions have empty body (do nothing) | to deal with this Returns string user | ||
Every applet does not need all three | inputs Assignment statement to string | ||
methods Override the ones you need Applet | Lines 25-26: As above, assigns input to | ||
container “draws itself” by calling method | secondNumber. 36. | ||
paint. 14. | 37 | 3.5 Adding Floating-Point Numbers. | |
15 | 3.3 Simple Java Applet: Drawing a | static method Double.parseDouble Converts | |
String. Method paint Lines 11-19 are the | String argument to a double Returns the | ||
declaration of paint Draws graphics on | double value Remember static method syntax | ||
screen void indicates paint returns | ClassName.methodName( arguments ) | ||
nothing when finishes task Parenthesis | Assignment statement sum an field, can use | ||
define parameter list - where methods | anywhere in class Not defined in init but | ||
receive data to perform tasks Normally, | still used. 37. | ||
data passed by programmer, as in | 38 | 3.5 Adding Floating-Point Numbers. | |
JOptionPane.showMessageDialog paint gets | Ends method init appletviewer (or browser) | ||
parameters automatically Graphics object | calls inherited method start start usually | ||
used by paint Mimic paint's first line. | used with multithreading Advanced concept, | ||
15. | in Chapter 16 We do not declare it, so | ||
16 | 3.3 Simple Java Applet: Drawing a | empty declaration in JApplet used Next, | |
String. Calls version of method paint from | method paint called Method drawRect( x1, | ||
superclass JApplet Should be first | y1, width, height ) Draw rectangle, upper | ||
statement in every applet’s paint method | left corner (x1, y1), specified width and | ||
Body of paint Method drawString (of class | height Line 45 draws rectangle starting at | ||
Graphics) Called using Graphics object g | (15, 10) with a width of 270 pixels and a | ||
and dot (.) Method name, then parenthesis | height of 20 pixels. 38. | ||
with arguments First argument: String to | 39 | 3.5 Adding Floating-Point Numbers. | |
draw Second: x coordinate (in pixels) | Sends drawString message (calls method) to | ||
location Third: y coordinate (in pixels) | Graphics object using reference g | ||
location Java coordinate system Measured | "The sum is" + sum - string | ||
in pixels (picture elements) Upper left is | concatenation sum converted to a string | ||
(0,0). 16. | sum can be used, even though not defined | ||
17 | 3.3 Simple Java Applet: Drawing a | in paint field, can be used anywhere in | |
String. Running the applet Compile javac | class Non-local variable. 39. | ||
WelcomeApplet.java If no errors, bytecodes | 40 | 3.6 Java Applet Internet and World | |
stored in WelcomeApplet.class Create an | Wide Web Resources. Many Java applet | ||
HTML file Loads the applet into | resources available java.sun.com/applets/ | ||
appletviewer or a browser Ends in .htm or | Many resources and free applets Has demo | ||
.html To execute an applet Create an HTML | applets from J2SDK Sun site | ||
file indicating which applet the browser | developer.java.sun.com/developer Tech | ||
(or appletviewer) should load and execute. | support, discussion forums, training, | ||
17. | articles, links, etc. Registration | ||
18 | 3.3 Simple Java Applet: Drawing a | required www.jars.com Rates applets, top | |
String. Simple HTML file | 1, 5 and 25 percent View best applets on | ||
(WelcomeApplet.html) Usually in same | web. 40. | ||
directory as .class file Remember, .class | 41 | 3.7 (Optional Case Study) Thinking | |
file created after compilation HTML codes | About Objects: Identifying the Classes in | ||
(tags) Usually come in pairs Begin with | a Problem Statement. Identifying classes | ||
< and end with > Lines 1 and 4 - | in a System Nouns of system to implement | ||
begin and end the HTML tags Line 2 - | elevator simulation. 41. | ||
begins <applet> tag Specifies code | 42 | 3.7 (Optional Case Study) Thinking | |
to use for applet Specifies width and | About Objects: Identifying the Classes in | ||
height of display area in pixels Line 3 - | a Problem Statement. Not all nouns pertain | ||
ends <applet> tag. 18. | to model (not highlighted) Company and | ||
19 | 3.3 Simple Java Applet: Drawing a | building not part of simulation Display, | |
String. appletviewer only understands | audio, and elevator music pertain to | ||
<applet> tags Ignores everything | presentation GUI, user of application, | ||
else Minimal browser Executing the applet | First and Second Floor buttons How user | ||
appletviewer WelcomeApplet.html Perform in | controls model only Capacity of elevator | ||
directory containing .class file. 19. | only a property Energy preservation not | ||
20 | 3.3 Simple Java Applet: Drawing a | modeled Simulation is the system Elevator | |
String. Running the applet in a Web | and elevator car are same references | ||
browser. 20. | Disregard elevator system for now. 42. | ||
21 | 3.4 Drawing Strings and Lines. More | 43 | 3.7 (Optional Case Study) Thinking |
applets First example Display two lines of | About Objects: Identifying the Classes in | ||
text Use drawString to simulate a new line | a Problem Statement. Nouns highlighted to | ||
with two drawString statements Second | be implemented in system Elevator button | ||
example Method g.drawLine(x1, y1, x2, y2 ) | and floor button separate functions | ||
Draws a line from (x1, y1) to (x2, y2) | Capitalize class names Each separate word | ||
Remember that (0, 0) is upper left Use | in class name also capitalized | ||
drawLine to draw a line beneath and above | ElevatorShaft, Elevator, Person, Floor, | ||
a string. 21. | ElevatorDoor, FloorDoor, ElevatorButton, | ||
22 | WelcomeApplet2.java 1. import 2. Class | FloorButton, Bell, and Light. 43. | |
WelcomeApplet2 (extends JApplet) 3. paint | 44 | 3.7 (Optional Case Study) Thinking | |
3.1 drawString 3.2 drawString on same x | About Objects: Identifying the Classes in | ||
coordinate, but 15 pixels down. 22. 1 // | a Problem Statement. Using UML to model | ||
Fig. 3.9: WelcomeApplet2.java 2 // | elevator system Class diagrams models | ||
Displaying multiple strings in an applet. | classes and relationships Model | ||
3 4 // Java packages 5 import | structure/building blocks of system | ||
java.awt.Graphics; // import class | Representing class Elevator using UML Top | ||
Graphics 6 import javax.swing.JApplet; // | rectangle is class name Middle contains | ||
import class JApplet 7 8 public class | class’ attributes Bottom contains class’ | ||
WelcomeApplet2 extends JApplet { 9 10 // | operations. 44. | ||
draw text on applet’s background 11 public | 45 | 3.7 (Optional Case Study) Thinking | |
void paint( Graphics g ) 12 { 13 // call | About Objects: Identifying the Classes in | ||
superclass version of method paint 14 | a Problem Statement. Class associations | ||
super.paint( g ); 15 16 // draw two | using UML Elided diagram Class attributes | ||
Strings at different locations 17 | and operations ignored Class relation | ||
g.drawString( "Welcome to", 25, | among ElevatorShaft, Elevator and | ||
25 ); 18 g.drawString( "Java | FloorButton Solid line is an association, | ||
Programming!", 25, 40 ); 19 20 } // | or relationship between classes Numbers | ||
end method paint 21 22 } // end class | near lines express multiplicity values | ||
WelcomeApplet2. | Indicate how many objects of class | ||
23 | HTML file Program Output. 23. 1 | participate association. 45. | |
<html> 2 <applet code = | 46 | 3.7 (Optional Case Study) Thinking | |
"WelcomeApplet2.class" width = | About Objects: Identifying the Classes in | ||
"300" height = | a Problem Statement. Diagram shows two | ||
"60"> 3 </applet> 4 | objects of class FloorButton participate | ||
</html> | in association with one object of | ||
24 | WelcomeLines.java 2. Class | ElevatorShaft FloorButton has two-to-one | |
WelcomeLines (extends JApplet) 3. paint | relationship with ElevatorShaft. 46. | ||
3.1 drawLine 3.2 drawLine 3.3 drawString | 47 | 3.7 (Optional Case Study) Thinking | |
Program Output. 24. 1 // Fig. 3.11: | About Objects: Identifying the Classes in | ||
WelcomeLines.java 2 // Displaying text and | a Problem Statement. Associations can be | ||
lines 3 4 // Java packages 5 import | named In diagram, “Requests” indicates | ||
java.awt.Graphics; // import class | association and arrow indicates direction | ||
Graphics 6 import javax.swing.JApplet; // | of association One object of FloorButton | ||
import class JApplet 7 8 public class | requests one object of class Elevator | ||
WelcomeLines extends JApplet { 9 10 // | Similar context with “Resets” and “Signals | ||
draw lines and a string on applet’s | Arrival” Aggregation relationship Implies | ||
background 11 public void paint( Graphics | whole/part relationship Some object “has” | ||
g ) 12 { 13 // call superclass version of | some object Object attached with diamond | ||
method paint 14 super.paint( g ); 15 16 // | is “owner” Object on other end is the | ||
draw horizontal line from (15, 10) to | “part” In diagram, elevator shaft “has an” | ||
(210, 10) 17 g.drawLine( 15, 10, 210, 10 | elevator and two floor buttons. 47. | ||
); 18 19 // draw horizontal line from (15, | 48 | 3.7 (Optional Case Study) Thinking | |
30) to (210, 30) 20 g.drawLine( 15, 30, | About Objects: Identifying the Classes in | ||
210, 30 ); 21 22 // draw String between | a Problem Statement. Fig. 3.23 Class | ||
lines at location (25, 25) 23 | diagram for the elevator model. 48. | ||
g.drawString( "Welcome to Java | 49 | 3.7 (Optional Case Study) Thinking | |
Programming!", 25, 25 ); 24 25 } // | About Objects: Identifying the Classes in | ||
end method paint 26 27 } // end class | a Problem Statement. The complete class | ||
WelcomeLines. | diagram for elevator model Several of many | ||
25 | HTML file. 25. 1 <html> 2 | and aggregates Elevator is aggregation of | |
<applet code = | ElevatorDoor, ElevatorButton and Bell | ||
"WelcomeLines.class" width = | Several of many associations Person | ||
"300" height = | “presses” buttons Person also “rides” | ||
"40"> 3 </applet> 4 | Elevator and “walks” across Floor. 49. | ||
Как сделать звук на всю 2003.ppt |
«Классы объектов C» - Упаковка и распаковка. Анатомия класса. С или с D или d Е или е. Console. World!"); return 0; } }. Вывод значений с фиксированной точностью Общий (general) формат. WriteLine("Hello. Определение простейшего класса в С#. Средства форматирования строк в С#. «Класс» и «объект» - два разных понятия.
«Интерфейсы. Контейнерные классы» - Monster Vasia. Дерево поиска. Стек. Очередь. Свойства нескольких интерфейсов. Программирование на языке высокого уровня. Пример использования класса. Контейнеры. Абстрактные структуры данных. Клонирование объектов. Операция. Преобразование. Способ реализации интерфейса. Отличия интерфейса от абстрактного класса.
«Классификация языков программирования» - Язык программирования Pascal относится к: Программа для компьютера представляет собой: Программа – отладчик; транслятор; библиотека стандартных программ и функций. Читай вопрос и выбирай ответ. Задание. Повтори способы записи алгоритма и виды программ переводчиков. Процедурным языкам; логическим языкам; объектно-ориентированным языкам.
«Язык XSL» - Свойства, определяющие локализацию объектов форматирования. Свойства padding-before. Очередность отображения. Свойства относительного позиционирования. Процессор. Количество соседних ячеек. Коэффициент масштабирования. Цвет верхней границы. Общие свойства фона. Свойство border. Отображаемое содержимое объекта.
«История развития языков программирования» - Структурированная величина. При использовании процедуры формальные параметры заменяются на фактические. Фундаментальных понятия языка. Синтаксическая диаграмма является графическим представлением значения метапеременной метаязыка. Француз Филип Кан разработал систему Турбо-Паскаль. Список наиболее употребительных обозначений типов данных, используемых в описаниях.
«Delphi» - Очищаем содержимое Edit-a. Edit для ввода и отображения цифр. 2. Кнопки действий. Процедура нажатия на кнопку с цифрой 1. Разместим на форме нужные нам компоненты: Кнопка вычитания. Кнопка извлечения синуса. MainMenu , в котором с помощью дизайнера создадим опции: О программе Вызов справки. Переменной mode присваиваем 1 – код, соответствующий операции сложения.