• 面向对象举例



    小王本来体重70kg,经过减肥,体重降到45kg,从这个问题领域中识别对象、类、属性、状态和状态的变化。
    1)类:人。
    2)对象:小王。
    3)属性:体重
    4)状态:70kg
    5)状态的变化:小王的减肥行为导致体重下降。



    class
    people { String name; int weight; public people() { } public void reduce() { int t = weight; weight -= 25; System.out.println(name + "的体重由原来的" + t + "kg减到" + weight + "kg"); } public static void main(String[] args) { people pp=new people(); pp.name="小王"; pp.weight=70; pp.reduce(); } }

    4、小王本来体重70kg,经过减肥,体重降到45kg,试从这个问题领域中识别对象、类、属性、状态和状态的变化。 1)  类:人。 2)  对象:小王。 3)  属性:体重。 4)  状态:70kg。
    5)  状态的变化:小王的减肥行为导致体重下降。 
    class  people {  String name;  int weight;   public people(){    }   public void reduce(){   int t=weight;   weight-=25;   System.out.println(name+"的体重由原来的"+t+"kg减到"+weight+"kg");  }









     public static void main(String[] args)   {   people pp=new people();   pp.name="小王";   pp.weight=70;    pp.reduce();  } }

  • 相关阅读:
    575. Distribute Candies
    242. Valid Anagram
    349. Intersection of Two Arrays
    290. Word Pattern
    389. Find the Difference
    httpModules 与 httpHandlers
    JS获取浏览器信息及屏幕分辨率
    asp.net 页面编码 设置的几种方法
    IIS是如何处理ASP.NET请求的
    VS2010常用插件介绍之Javascript插件(一)
  • 原文地址:https://www.cnblogs.com/youshashuosha/p/5034455.html
Copyright © 2020-2023  润新知