zoukankan      html  css  js  c++  java
  • 电视练习

    public class FormatTest {
    /*public static int maxStringLength;

    public static double minSize;*/

    private static int maxStringLength;

    private static double minSize;

    public static int getMaxStringLength() {
    return maxStringLength;
    }

    public static void setMaxStringLength(int maxStringLength) {
    FormatTest.maxStringLength = maxStringLength;
    }

    public static double getMinSize() {
    return minSize;
    }

    public static void setMinSize(double minSize) {
    FormatTest.minSize = minSize;
    }

    public static boolean testStringLength( String a){
    if(a.length()<=maxStringLength){
    return true;
    }else{
    return false;
    }
    }

    public static boolean testDouble(double b){
    if(b>=minSize){
    return true;
    }else{
    return false;
    }
    }
    }

    再创建一个类

    public class TestProgram {

    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Scanner s=new Scanner(System.in);
    System.out.println("请输入一个字符串");
    String a=s.next();
    System.out.println("请输入一个数");
    double b=s.nextDouble();

    /*FormatTest ft = new FormatTest();
    ft.maxStringLength=12;
    ft.minSize=100;

    System.out.println(ft.testStringLength(A));
    System.out.println(ft.testDouble(b))*/

    FormatTest.setMaxStringLength(12);
    FormatTest.setMinSize(100.000);

    System.out.println(FormatTest.testStringLength(a));
    System.out.println(FormatTest.testDouble(b));
    }

    }

    再创一个类

    public class Television {
    private int channel;
    private int volume;

    public int getChannel() {
    return channel;
    }

    public void setChannel(int channel) {
    if(channel>=2&&channel<=999){

    this.channel = channel;
    }else{
    System.out.println("没有这个频道,请重新开始");
    }

    }

    public int getVolume() {
    return volume;
    }

    public void setVolume(int volume) {
    if(volume>=0&&volume<=10){
    this.volume = volume;
    }else{
    System.out.println("输入错误,请重新输入音量");
    }

    }

    public Television(){

    }

    public Television(int channel,int volume ){
    this.channel=channel;
    this.volume=volume;
    }
    }

    最后创一个类运行

    public class WatchTelevision {

    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Scanner s=new Scanner(System.in);
    System.out.println("请输入频道");
    int channel=s.nextInt();
    System.out.println("请调节音量");
    int volume=s.nextInt();

    Television tv=new Television();
    tv.setChannel(channel);
    tv.setVolume(volume);


    if(tv.getChannel()>=2&&tv.getChannel()<=999){

    System.out.println("你正在收看"+tv.getChannel()+"频道");
    System.out.println("当前正在播放:12345");
    }else{
    System.out.println("请输入正确频道");
    }

    if(tv.getVolume()>=0&&tv.getVolume()<=10){
    System.out.println("当前音量为"+tv.getVolume());
    }else{

    System.out.println("没有此音量");
    }

    }

    }

    感觉还是有点不熟悉

  • 相关阅读:
    SQL Server 内存管理在64位时代的改变
    SQL Server 的内存分类
    SQL Server sp_configure 控制内存使用
    SQL Server 内存使用量下降问题
    SQL Server 与 Windows 内存使用上的约定
    MYSQL 为表指定文件位置 data directory
    SQL Server 与内存相关的术语
    SQL Server 为索引启动硬件加速(分区)的 2 方法
    SQL Server 提高创建索引速度的 2 个方法
    SQL Server 中索引的禁用与删除
  • 原文地址:https://www.cnblogs.com/whj1986556646/p/5539783.html
Copyright © 2011-2022 走看看