zoukankan      html  css  js  c++  java
  • 语言的基础是一组记号和一组规则

    是用于编写计算机程序的语言。

    语言的基础是一组记号和一组规则。

    根据规则由记号构成的记号串的总体就是语言。

    在程序设计语言中,这些记号串就是程序。

    程序设计语言包含三个方面,即语法、语义和语用。

    语法表示程序的结构或形式,亦即表示构成程序的各个记号之间的组合规则,但不涉及这些记号的特定含义,也不涉及使用者。语义表示程序的含义,亦即表示按照各种方法所表示的各个记号的特定含义,但也不涉及使用着,语用表示程序与使用的关系。

      1 package Com.TableTest;
      2 
      3 class ElectricVehicle extends TableText_15 {
      4     // 私有属性:电池品牌
      5     private String diannchi;
      6     // 公有的get***/set***方法完成属性封装
      7  
      8     public String getDiannchi() {
      9         return diannchi;
     10     }
     11  
     12     public void setDiannchi(String diannchi) {
     13         this.diannchi = diannchi;
     14     }
     15  
     16     // 重写运行方法,描述内容为:这是一辆使用**牌电池的电动车。其中**的数据由属性提供
     17     public String work() {
     18         String str="这是一辆使用"+this.getDiannchi()+"牌电池的电动车";
     19         return str;
     20 }
     21   
     22 }
     23 
     24 class Bicycle extends TableText_15 {
     25     
     26     public Bicycle(String pinpai, String color) {
     27         
     28         super.pinpai = pinpai;
     29         super.color = color;
     30     }
     31  // 重写运行方法,描述内容为:这是一辆**颜色的,**牌的自行车。其中**的数据由属性提供
     32  public String work() {
     33      String str="这是一辆"+this.getColor()+"颜色的 ,"+this.getPinpai()+"牌的自行车";
     34      System.out.println(str);
     35      return str;
     36  }
     37  
     38 }
     39 
     40  
     41 
     42  class TableText_15 {
     43     // 私有属性:品牌、颜色、轮子(默认2个)、座椅(默认 1个)
     44     public String pinpai;
     45     public String color;
     46     private int wheelNum=2;
     47     private int chairNum=1;
     48     // 无参构造方法
     49     public TableText_15() {
     50          
     51     }
     52      
     53     // 双参构造方法,完成对品牌和颜色的赋值
     54     public TableText_15(String pinpai, String color) {
     55         super();
     56         this.pinpai = pinpai;
     57         this.color = color;
     58     }
     59     // 四参构造方法,分别对所有属性赋值
     60     public TableText_15(String pinpai, String color, int wheelNum, int chairNum) {
     61         super();
     62         this.pinpai = pinpai;
     63         this.color = color;
     64         this.wheelNum = wheelNum;
     65         this.chairNum = chairNum;
     66     }
     67     
     68    // 公有的get***/set***方法完成属性封装
     69     public String getPinpai() {
     70         return pinpai;
     71     }
     72  
     73     public void setPinpai(String pinpai) {
     74         this.pinpai = pinpai;
     75     }
     76  
     77     public String getColor() {
     78         return color;
     79     }
     80  
     81     public void setColor(String color) {
     82         this.color = color;
     83     }
     84  
     85     public int getWheelNum() {
     86         return wheelNum;
     87     }
     88  
     89     public void setWheelNum(int wheelNum) {
     90         this.wheelNum = wheelNum;
     91     }
     92  
     93     public int getChairNum() {
     94     return chairNum;
     95     }
     96     public void setChairNum(int ChairNum){
     97     this.chairNum=ChairNum;
     98     }
     99     
    100  
    101     
    102     public static void main(String[] args){
    103         
    104         TableText_15 t=new TableText_15("borter","white");
    105         t.getColor();
    106         t.getPinpai();
    107         System.out.println(t.getColor());
    108         System.out.println(t.getPinpai());
    109         
    110         ElectricVehicle e=new ElectricVehicle();
    111         
    112         e.setDiannchi("borter");
    113         System.out.println(e.work());
    114         Bicycle b=new Bicycle("borter","white");
    115         System.out.println(b.work());
    116         
    117         
    118     }
    119   
    120  }
    121  
    122 
    123 
    124     
  • 相关阅读:
    python3之Django内置模板标签和过滤器
    JavaScript(1)
    python3之Django基础篇
    CSS
    HTML
    python3之SQLAlchemy
    python3之memcached
    web服务器-nginx虚拟主机
    web服务器-nginx默认网站
    web服务器-Nginx下载限速
  • 原文地址:https://www.cnblogs.com/borter/p/9393568.html
Copyright © 2011-2022 走看看