forked from DuGuQiuBai/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c8c8a7c
commit 7b3c6d6
Showing
44 changed files
with
1,045 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
������� | ||
��������ǻ���������̵ı��˼�� | ||
|
||
������̣��Լ�һ��������ɲ�����ǿ�����ǹ��̡� | ||
��������ñ��˵IJ�����ǿ�����ǽ���� | ||
|
||
��������˼���ص㣺 | ||
A:��һ�ָ���������˼��ϰ�ߵ�˼�� | ||
B:���Խ����ӵ������ | ||
C:�����Ǵ�ִ���߱����ָ���� | ||
��ɫ������ת�� | ||
|
||
������ | ||
A:ϴ�·� | ||
������̣������ӽ�ˮ,��ϴ�·�-->���·��ӽ�ȥ����-->��������·�-->Ưϴ�·�-->š��-->���¼������� | ||
��������·��ӵ�ϴ�»�����ϴ�·�,������������-->���¼������� | ||
|
||
B:�Է� | ||
������̣�ȥ�������,����-->ϴ��,ϴ��-->�в�,����-->����-->�˲�,ʢ��-->���� | ||
�������ȥ����-->���÷���Ա�ļDz˹���-->���ó�ʦ�ij��˹���-->���÷���Ա�Ķ˲˹���-->����-->���� | ||
|
||
������һ���������������Щ���顣 | ||
|
||
C:����� | ||
������̣���������-->������-->��������Գ�-->���ұȽ�-->ѡ���Լ�ϲ���IJ��ּۻ���-->�ؼ� | ||
�������������-->����-->�������� | ||
|
||
�������� | ||
���Ѵ���װ������ | ||
���裺 | ||
A:������ | ||
B:�������� | ||
C:�رձ����� | ||
|
||
A:������� | ||
a:������ | ||
b:�������� | ||
c:�رձ����� | ||
|
||
���룺 | ||
|
||
class Demo { | ||
public static void main(String[] args) { | ||
//System.out.println("������"); | ||
//System.out.println("��������"); | ||
//System.out.println("�رձ�����"); | ||
|
||
//���ܴ����ŵIJ�����Ҫ����� | ||
//���ң�������������ܵĴ���Ƚ϶� | ||
//���ʱ����ʵ����Ӧ���÷����Ľ� | ||
//���ù��� | ||
open(); | ||
in(); | ||
close(); | ||
|
||
//open(); | ||
//open(); | ||
} | ||
|
||
public static void open() { | ||
System.out.println("������"); | ||
} | ||
|
||
public static void in(){ | ||
System.out.println("��������"); | ||
} | ||
|
||
public static void close() { | ||
System.out.println("�رձ�����"); | ||
} | ||
} | ||
|
||
B:������� | ||
Ҫ�������������������ҵ����仰�� | ||
a:������������� | ||
UML(ͳһ��ģ����) ������ȡ�� | ||
b:����ÿ��������Щ���� | ||
c:����������Ĺ�ϵ | ||
|
||
�������ǵ����⣺ | ||
�Ѵ���װ������ | ||
|
||
a:������������� | ||
���� | ||
���� | ||
������(��main�������Ǹ���) | ||
b:����ÿ��������Щ���� | ||
����:��ȥ | ||
����:��,�ر� | ||
������:main | ||
c:����������Ĺ�ϵ | ||
�ڲ������е��ñ�����ʹ�����Ĺ��� | ||
|
||
���룺 | ||
class ���� { | ||
public static void in(){ | ||
System.out.println("��������"); | ||
} | ||
} | ||
|
||
class ���� { | ||
public static void open() { | ||
System.out.println("������"); | ||
} | ||
|
||
public static void close() { | ||
System.out.println("�رձ�����"); | ||
} | ||
} | ||
|
||
class ������ { | ||
public static void main(String[] args) { | ||
�����open(); | ||
�����in(); | ||
�����close(); | ||
} | ||
} | ||
|
||
ѧ��������� | ||
�Ժ����������һ�������ʱ���������Ƿ��ж��������������ܣ��У����Ǿ�ֱ��ʹ�ü��ɡ� | ||
���û�У����Ǿ��Լ�����һ���࣬��ɹ��ܣ����������Ը������á� |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
����ѧϰ������ԣ���Ϊ�˰���ʵ�������������������ʵ����Ϣ�������� | ||
|
||
����Ҫ��ͨ����������������������Ҫ֪������������α���ģ� | ||
��� | ||
���� �������������Ϣ(��������) | ||
��Ϊ �������ܹ���ʲô(������Ϊ) | ||
|
||
����ѧϰ����java���ԣ���java����������ĵ�λ���ࡣ | ||
���ԣ�����Ҫ������ͨ���������֡� | ||
��� | ||
���� �������������Ϣ(��������) | ||
��Ϊ �������ܹ���ʲô(������Ϊ) | ||
|
||
�ࣺ | ||
��Ա���� �������������Ϣ(��������) | ||
��Ա���� �������ܹ���ʲô(������Ϊ) | ||
|
||
�ࣺ��һ����ص����Ժ���Ϊ�ļ��� | ||
�����Ǹ�������ľ������� | ||
|
||
������ | ||
ѧ������ | ||
�����Ƕ��� |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
第一步:分析事物 | ||
手机事物: | ||
属性:品牌,价格,颜色 | ||
行为:打电话,发短信 | ||
第二步:把事物转换为类 | ||
手机类: | ||
成员变量:品牌,价格,颜色 | ||
成员方法:打电话,发短信 | ||
第三步:把类用英文体现 | ||
Phone: | ||
成员变量:brand,price,color | ||
成员方法:call(String name),sendMessage() | ||
第四步:写代码体现 | ||
成员变量:其实就是一个变量,只不过定义在类中方法外,并且也可以不给初始化值。 | ||
成员方法:其实就是一个方法,只不过不需要static了。 | ||
*/ | ||
//这是我的手机类 | ||
class Phone { | ||
//品牌 | ||
String brand; | ||
//价格 | ||
int price; | ||
//颜色 | ||
String color; | ||
|
||
//打电话的方法 | ||
public void call(String name) { | ||
System.out.println("给"+name+"打电话"); | ||
} | ||
|
||
//发短信的方法 | ||
public void sendMessage() { | ||
System.out.println("群发短信"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
第一步:分析事物 | ||
学生事物: | ||
属性:学号,姓名,年龄 | ||
行为:学习,吃饭,睡觉 | ||
第二步:把事物转换为类 | ||
学生类: | ||
成员变量:学号,姓名,年龄 | ||
成员方法:学习,吃饭,睡觉 | ||
第三步:把类用英文体现 | ||
Student: | ||
成员变量:sid,name,age | ||
成员方法:study(),eat(),sleep() | ||
第四步:写代码体现 | ||
成员变量:其实就是一个变量,只不过定义在类中方法外,并且也可以不给初始化值。 | ||
成员方法:其实就是一个方法,只不过不需要static了。 | ||
练习: | ||
手机 | ||
*/ | ||
//这是我的学生类 | ||
class Student { | ||
//成员变量 | ||
//学号 | ||
String sid; | ||
//姓名 | ||
String name; | ||
//年龄 | ||
int age; | ||
|
||
//成员方法 | ||
//学习的方法 | ||
public void study() { | ||
System.out.println("学生爱学习"); | ||
} | ||
|
||
//吃饭的方法 | ||
public void eat() { | ||
System.out.println("学生要吃饭"); | ||
} | ||
|
||
//睡觉的方法 | ||
public void sleep() { | ||
System.out.println("学生想睡觉"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
一个.java文件中可以有多个类吗? | ||
可以。 | ||
如果类用public修饰后,它应该修饰哪个类呢? | ||
修饰带main方法的。并且一个类中只应该有一个类被public修饰 | ||
目前不写public修饰的。 | ||
如何在测试类中使用一个类呢? | ||
创建对象使用类的成员 | ||
如何创建对象呢? | ||
格式: | ||
类名 对象名 = new 类名(); | ||
如何使用类的成员呢? | ||
成员变量:对象.变量名; | ||
成员方法:对象.方法名(...); | ||
注意: | ||
引用类型的默认值是null。 | ||
*/ | ||
class Student { | ||
//学号 | ||
String sid; | ||
//姓名 | ||
String name; | ||
//年龄 | ||
int age; | ||
|
||
//学习的方法 | ||
//学习的方法 | ||
public void study() { | ||
System.out.println("学生爱学习"); | ||
} | ||
|
||
//吃饭的方法 | ||
public void eat() { | ||
System.out.println("学生要吃饭"); | ||
} | ||
|
||
//睡觉的方法 | ||
public void sleep() { | ||
System.out.println("学生想睡觉"); | ||
} | ||
} | ||
|
||
class StudentDemo { | ||
public static void main(String[] args) { | ||
//创建学生对象 | ||
Student s = new Student(); | ||
|
||
//输出对象名 | ||
System.out.println(s); //Student@1afb7ac7 | ||
|
||
//输出成员变量 | ||
System.out.println("学号是:"+s.sid); //null | ||
System.out.println("姓名是:"+s.name);//null | ||
System.out.println("年龄是:"+s.age); //0 | ||
System.out.println("--------------"); | ||
|
||
//给成员变量赋值 | ||
s.sid = "itcast001"; | ||
s.name = "林青霞"; | ||
s.age = 28; | ||
|
||
//再次输出成员变量 | ||
System.out.println("学号是:"+s.sid); //itcast001 | ||
System.out.println("姓名是:"+s.name);//林青霞 | ||
System.out.println("年龄是:"+s.age); //28 | ||
System.out.println("--------------"); | ||
|
||
//使用成员方法 | ||
s.study(); | ||
s.eat(); | ||
s.sleep(); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
手机类 | ||
成员变量:品牌,价格,颜色 | ||
成员方法:打电话,发短信 | ||
*/ | ||
class Phone { | ||
//品牌 | ||
String brand; | ||
//价格 | ||
int price; | ||
//颜色 | ||
String color; | ||
|
||
//打电话的方法 | ||
public void call(String name) { | ||
System.out.println("给"+name+"打电话"); | ||
} | ||
|
||
//发短信 | ||
public void sendMessage() { | ||
System.out.println("群发短信"); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class PhoneDemo { | ||
public static void main(String[] args) { | ||
//创建对象 | ||
Phone p = new Phone(); | ||
|
||
//使用成员变量 | ||
System.out.println("品牌是:"+p.brand); | ||
System.out.println("价格是:"+p.price); | ||
System.out.println("颜色是:"+p.color); | ||
System.out.println("----------------"); | ||
|
||
//给成员变量赋值 | ||
p.brand = "三星"; | ||
p.price = 2999; | ||
p.color = "蓝色"; | ||
|
||
//再次使用成员变量 | ||
System.out.println("品牌是:"+p.brand); | ||
System.out.println("价格是:"+p.price); | ||
System.out.println("颜色是:"+p.color); | ||
System.out.println("----------------"); | ||
|
||
//调用成员方法 | ||
//String name = "林青霞"; | ||
//p.call(name); | ||
p.call("林青霞"); | ||
p.sendMessage(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class Student { | ||
//学号 | ||
String sid; | ||
//姓名 | ||
String name; | ||
//年龄 | ||
int age; | ||
|
||
//学习的方法 | ||
//学习的方法 | ||
public void study() { | ||
System.out.println("学生爱学习"); | ||
} | ||
|
||
//吃饭的方法 | ||
public void eat() { | ||
System.out.println("学生要吃饭"); | ||
} | ||
|
||
//睡觉的方法 | ||
public void sleep() { | ||
System.out.println("学生想睡觉"); | ||
} | ||
} |
Oops, something went wrong.