cos.java
来自「本书透彻讲解了经典的《设计模式:可复用面向对象软件的基础》一书涵盖的23种基本设」· Java 代码 · 共 46 行
JAVA
46 行
package com.oozinoz.function;
/*
* Copyright (c) 2001 Steven J. Metsker.
*
* Steve Metsker makes no representations or warranties about
* the fitness of this software for any particular purpose,
* including the implied warranty of merchantability.
*
* Please use this software as you wish with the sole
* restriction that you may not claim that you wrote it.
*/
/**
* Wrap the Math.cos() function around a given source.
*
* @author Steven J. Metsker
*/
public class Cos extends Function
{
/**
* Construct a cosine function that decorates the
* provided source function.
*
* @param Function the source function that this function
* wraps
*/
public Cos(Function f)
{
super(f);
}
/**
* Return Math.cos() applied to the source function's value
* at time t.
*
* @param t the time function that goes 0 to 1 and that
* other functions use as a parameter
*
* @return Math.cos() applied to the source function's value
* at time t.
*/
public double f(double t)
{
return Math.cos(source[0].f(t));
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?