`
zhangjiali123
  • 浏览: 1287 次
文章分类
社区版块
存档分类
最新评论

book

 
阅读更多
一个book类,放置在包MyPackage中,要求封装数据成员:name,price;name的类型为字符串;price的类型为双精度;设计有参得构造方法,初始化数据成员,对每个数据设计getter和setter方法,并对数据成员设计一个toString方法。
package com.MyPackage;
import java.util.Scanner;
public class book {
     private static String name;
     private static double price;
     public void q(String name,double price){
    this.name =name;
    this.price =price;
    }
     public void setName(String name){
    this.name =name;
   
     }
     public String getName(){
    return name;
     }
     public void setPrice(double price){
    this.price =price;
   
     }
     public double getPrice(){
    return price;
     }
     public static void main(String[]args){
   
   
    System.out.print("name:"+"zjl"+"\n");
    System.out.print("price:"+100000+"\n");
     }
}
分享到:
评论

相关推荐

    F1BOOK控件实例

    而“F1BOOK控件”是专为VB6设计的一种特殊控件,它旨在替代Excel,提供更便捷的打印功能。这个“F1BOOK控件实例”可能是包含了一些示例代码和教程,帮助开发者更好地理解和应用这个控件。 F1BOOK控件的核心价值在于...

    Book-Crossing数据集

    Book-Crossing数据集是网上的Book-Crossing图书社区的278,858个用户对271,379本书进行的评分,包括显式和隐式的评分。这些用户的年龄等人口统计学属性(demographic feature)都以匿名的形式保存并供分析。这个数据集...

    F1book中文使用说明

    **F1book中文使用说明** **一、F1book简介** F1book是一款专为IT专业人士设计的电子手册工具,它提供了丰富的技术文档查阅功能,旨在帮助用户快速找到所需的技术信息,提高工作效率。这款软件以其易用性、全面性和...

    ng-book2-book-angular-6-r70

    ng-book2-book-angular-6该书最新版R70. This book aims to be the single most useful resource on learning Angular. By the time you’re done reading this book, you (and your team) will have everything you...

    f1book6 delphi c++ 表格控件

    标题中的“f1book6 delphi c++ 表格控件”指的是一个专门用于Delphi和C++ Builder开发环境的表格控件库,名为F1Book6。这个控件库是为了帮助开发者更轻松地创建类似Excel的电子表格应用程序,提供丰富的功能和自定义...

    ng-book: The Complete Book on Angular 6, r68

    Ready to Master Angular 6? What if you could master the entire ...You will learn what you need to know to work professionally with ng-book: The Complete Book on Angular 6 or get your money back.

Global site tag (gtag.js) - Google Analytics