zoukankan      html  css  js  c++  java
  • 面向对象—汽车

     1 package com.hanqi.z1p1;
     2 
     3 public class Jidongche {
     4 
     5     String Number;
     6     int Speed;
     7     double Weight;
     8     
     9     int speedUp(int Speed)
    10     {
    11         this.Speed+=Speed;
    12         System.out.println("车牌号为"+this.Number+"现在的车速是:"+this.Speed);
    13         return this.Speed;
    14     }
    15     
    16     int speedDown(int Speed)
    17     {
    18         this.Speed-=Speed;
    19         System.out.println("车牌号为"+this.Number+"现在的车速是:"+this.Speed);
    20         return this.Speed;
    21     }
    22     
    23     String setNumber(String Number)
    24     {
    25         this.Number=Number;
    26         System.out.println("修改后的车牌号是:"+this.Number);
    27         return this.Number;
    28     }
    29     
    30     void getWeight()
    31     {
    32         System.out.println("车牌号为"+this.Number+"的载重量为:"+this.Weight);
    33     }
    34     
    35     Jidongche()
    36     {
    37         Number="XX1234";
    38         Speed=100;
    39         Weight=100;
    40     }
    41     
    42     Jidongche(String Number,int Speed,double Weight)
    43     {
    44         this.Number=Number;
    45         this.Speed=Speed;
    46         this.Weight=Weight;
    47     }
    48     
    49     public static void main(String[] args) {
    50         // TODO 自动生成的方法存根
    51 
    52         Jidongche j1=new Jidongche();
    53         System.out.println(j1.Number);
    54         j1.setNumber("辽A9752");
    55         j1.speedUp(100);
    56         j1.getWeight();
    57         
    58         Jidongche j2=new Jidongche("辽B5086",150,200);
    59         j2.speedDown(50);
    60         j2.speedUp(120);
    61         
    62         System.out.println("j1的所有信息:"+j1.Number+" "+j1.Speed+" "+j1.Weight+" ");
    63         System.out.println("j2的所有信息:"+j2.Number+" "+j2.Speed+" "+j2.Weight+" ");
    64         
    65         
    66     }
    67 
    68 }
  • 相关阅读:
    compareTo冒泡比较时间字符串
    RestTemplate
    poi 处理空单元格
    Linux执行Java文件
    cmd 运行 java 文件
    @RequestParam 引发的编译问题
    linux 下安装与使用
    ajax请求 Provisional headers are show
    JWT加密
    Web API Filter
  • 原文地址:https://www.cnblogs.com/yg6405816/p/5514930.html
Copyright © 2011-2022 走看看