zoukankan      html  css  js  c++  java
  • 2020-07-30日报博客

    2020-07-30日报博客

    1.完成的事情:

    • 完成CodeGym Java核心 level 11部分,并完成练习题

    2.遇到的问题:

    • OOP的具体定义。

    3.明日计划:

    • 继续学习Java。
    /*taskKey="zh.codegym.task.task11.task1123"
    
    最小和最大
    
    编写返回数组的最小和最大数字的方法。
    
    
    Requirements:
    1.	程序不得从键盘读取数据。
    2.	不要更改 Pair 类。
    3.	不要更改 main 方法。
    4.	完成编写 getMinimumAndMaximum 方法。它必须返回一个包含最小值和最大值的对。
    5.	程序必须返回正确的结果。
    6.	getMinimumAndMaximum() 方法不应修改 inputArray 数组。*/
    
    
    package zh.codegym.task.task11.task1123;
    
    public class Solution {
    
        public static void main(String[] args) throws Exception {
            int[] data = new int[]{1, 2, 3, 5, -2, -8, 0, 77, 5, 5};
    
            Pair<Integer, Integer> result = getMinimumAndMaximum(data);
    
            System.out.println("最小值为 " + result.x);
            System.out.println("最大值为 " + result.y);
        }
    
        public static Pair<Integer, Integer> getMinimumAndMaximum(int[] array) {
            if (array == null || array.length == 0) {
                return new Pair<Integer, Integer>(null, null);
            }
            int max = array[0], min = array[0];
            for (int i = 0; i < array.length; i++) {
                if (array[i] > max){
                    max = array[i];
                }
                if (array[i] < min){
                    min = array[i];
                }
            }
    
            return new Pair<Integer, Integer>(min, max);
        }
    
        public static class Pair<X, Y> {
            public X x;
            public Y y;
    
            public Pair(X x, Y y) {
                this.x = x;
                this.y = y;
            }
        }
    }
    
    /*taskKey="zh.codegym.task.task11.task1122"
    
    拯救国际象棋俱乐部
    
    在每种象棋类中添加共同基础类 ChessPiece。
    
    
    Requirements:
    1.	在 Solution 类中添加 public ChessPiece 类。
    2.	King 类必须继承 ChessPiece 类。
    3.	Queen 类必须继承 ChessPiece 类。
    4.	Rook 类必须继承 ChessPiece 类。
    5.	Knight 类必须继承 ChessPiece 类。
    6.	Bishop 类必须继承 ChessPiece 类。
    7.	Pawn 类必须继承 ChessPiece 类。*/
    
    
    package zh.codegym.task.task11.task1122;
    
    /* 
    拯救国际象棋俱乐部
    */
    
    public class Solution {
        public static void main(String[] args) {
        }
        public class ChessPiece {
    
        }
    
        public class King extends ChessPiece {
        }
    
        public class Queen extends ChessPiece {
        }
    
        public class Rook extends ChessPiece {
        }
    
        public class Knight extends ChessPiece {
        }
    
        public class Bishop extends ChessPiece {
        }
    
        public class Pawn extends ChessPiece {
        }
    }
    
  • 相关阅读:
    判断一个序列是否是另一个序列的前缀
    Ant-打增量包
    cas-单点登录-应用说明
    firebug离线安装方法-拖入法
    oracle-获取数据库中所有表的注释 comments
    跨浏览器的placeholder – 原生JS版
    birt IE8 IE9 兼容问题
    websphere部署--web应用-以自己的项目为例
    JSP-页面跳转大全
    Oracle中Union与Union All的区别(适用多个数据库)
  • 原文地址:https://www.cnblogs.com/gongyunlong-blogs/p/13451016.html
Copyright © 2011-2022 走看看