1 package day05_javase;
2 /**
3 * 我要开车去丽江,这个句话中,有三个实物名词,“我”“车”“丽江”,所以以实物名称作为类class
4 *里面的“开”“去”,两个动词,以动词为方法,
5 *注意。类的名字最好大写,因为被别的地方调用的时候,new时就可以用小写的名字作为新的名字了
6 */
7 public class Driver {
8 public static void main(String[] args) {
9 Person person=new Person();
10 person.driverCar();
11 Car car=new Car();
12 car.Driverme();
13 // Style style=new Style();
14 // style.color();
15 //System.out.println("123456");
16 }
17 }
18 class Person{
19 //属性:
20 String name="Me";
21 Car mycar=new Car();
22 //人开车中的'开'这个方法
23 public void driverCar(){
24 mycar.Driverme();
25 System.out.println("车不错啊");
26 }
27 public void go(Place p){ //人车去哪里,这个新的方法。隶属于人这个实物类
28 System.out.println(" I will "+p+"here");
29 }
30 }
31 class Car{ //车这个实物类
32 //属性:
33 int wheel=4;
34 int speed=120;
35 //"去"这个动作类
36 public void Driverme(){
37 System.out.println("我以"+speed+"速度狂奔");
38 }
39 }
40 class Place{ //丽江这个实物类
41 String nameString="丽江";
42
43 }