显示所有线性元素

显示所有线性元素

分三部分

代码如下:

一部分

package Day05;

public class Circle {

private double radius = 1.0;

final static double pi = 3.1415926;

/**
* @param radius
*/
public Circle(double radius) {
this.radius = radius;
}
/**
*
*/
public Circle() {
this(10.0);
}

public double getRadius() {
return this.radius;
}
public void setRadius(double radius) {
this.radius = radius;
}

double getArea() {
return radius * radius * Math.PI;
}

public static String getName() {
return "Circle";
}

@Override
public String toString() {
return "Circle [radius=" + radius + "]";
}

}

二部分

package Day06;
import java.util.Date;

public class Loan {
//年利率
private double annualInterestRate;
//贷款年限
private int numberOfYears;
//贷款总额
private double loanAmount;
//贷款生成时间
private Date loanDate;

/**
*
*/
public Loan() {
this(0, 1, 1, new Date());
}

/**
* @param annualInterestRate
* @param numberOfYears
* @param loanAmount
*/
public Loan(double annualInterestRate, int numberOfYears, double loanAmount) {
this.annualInterestRate = annualInterestRate;
this.numberOfYears = numberOfYears;
this.loanAmount = loanAmount;
this.loanDate = new Date();
}

/**
* @param annualInterestRate
* @param numberOfYears
* @param loanAmount
* @param loanDate
*/
public Loan(double annualInterestRate, int numberOfYears,
double loanAmount, Date loanDate) {
this.annualInterestRate = annualInterestRate;
this.numberOfYears = numberOfYears;
this.loanAmount = loanAmount;
this.loanDate = loanDate;
}

/**
* @return the annualInterestRate
*/
public double getAnnualInterestRate() {
return annualInterestRate;
}

/**
* @param annualInterestRate the annualInterestRate to set
*/
public void setAnnualInterestRate(double annualInterestRate) {
this.annualInterestRate = annualInterestRate;
}

/**
* @return the numberOfYears
*/
public int getNumberOfYears() {
return numberOfYears;
}

/**
* @param numberOfYears the numberOfYears to set
*/
public void setNumberOfYears(int numberOfYears) {
this.numberOfYears = numberOfYears;
}

/**
* @return the loanAmount
*/
public double getLoanAmount() {
return loanAmount;
}

/**
* @param loanAmount the loanAmount to set
*/
public void setLoanAmount(double loanAmount) {
this.loanAmount = loanAmount;
}

/**
* @return the loanDate
*/
public Date getLoanDate() {
return loanDate;
}

/**
* @param loanDate the loanDate to set
*/
public void setLoanDate(Date loanDate) {
this.loanDate = loanDate;
}

/**
* 计算月还款数额
*/
public double getMonthlyPayment() {
double monthlyInterestRate = this.annualInterestRate / 1200;
double monthPayment =
this.loanAmount * monthlyInterestRate
/ (1 - 1 / Math.pow(1 + monthlyInterestRate, this.numberOfYears * 12));
return monthPayment;
}

/**
* 计算还款总金额
*/
public double getTotalPayment() {
return this.getMonthlyPayment() * this.numberOfYears * 12;
}

/**
* 计算贷款结清时间
*/
@SuppressWarnings("deprecation")
public Date getLoanPaidDate() {
Date loanDay = this.loanDate;
loanDay.setYear(loanDay.getYear() + this.numberOfYears);
return loanDay;
}

@Override
public String toString() {
return "Loan [annualInterestRate=" + annualInterestRate
+ ", numberOfYears=" + numberOfYears + ", loanAmount="
+ loanAmount + ", loanDate=" + loanDate + "]";
}

}

三部分

package Day07;

import java.util.ArrayList;
import java.util.Date;

import Day05.Circle;
import Day06.Loan;

public class Homework02 {
public static void main(String[] args) {
ArrayList arr = new ArrayList();
arr.add(new Loan());
arr.add(new Date());
arr.add("avb");
arr.add(new Circle());
for (int i = 0; i < arr.size(); i++) {
System.out.println(arr.get(i).toString());
}
}
}

时间: 2024-10-02 11:09:36

显示所有线性元素的相关文章

2016-06-02 获取系统当前日期和时间并显示在某个元素上

1. <script> window.onload=function(){ getDateAndTime(); setInterval(getDateAndTime,1000); } //获取系统的日期和时间并显示在某个元素上 function getDateAndTime(){ var myDate = new Date(); var year = myDate.getFullYear(); var month = myDate.getMonth()+1; var day = myDate.

页面滚动显示或隐藏元素Headroom.js插件帮助你实现滚动效果

Headroom.js 是什么? Headroom.js 是一个轻量级.高性能的JS小工具(不依赖任何工具库!),它能在页面滚动时做出响应.此页面顶部的导航条就是一个鲜活的案例,当页面向下滚动时,导航条消失,当页面向上滚动时,导航条就出现了. Headroom.js 有什么用? 固定页头(导航条)可以方便用户在各个页面之间切换.但是这也会带来些问题…本文原创博客地址:http://www.cnblogs.com/unofficial官网地址:www.pushself.com) 大屏幕一般都是宽度

如何显示哪个 DOM 元素触发了事件

我们如果想显示DOM元素触发了事件,直接用event.target就可以实现,见如代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>target</title> <script type="text/javascript" src="../js/jquery.min.js"></s

【jQuery/CSS】显示或隐藏元素

1. CSS分别有display.visibility两个样式可以用于隐藏或显示HTML元素 1) display样式有多个类型的值可选择,默认值为inline,隐藏后会释放元素所占用的页面空间(详见:点击打开链接) style="display: none;" document.getElementById("div1").style.display="none";//隐藏 document.getElementById("div1&

visibility, opacity,dispay 几个显示或者隐藏元素的区别

1. visibility: 规定元素是否可见 可能的取值: inherit:规定元素从父级元素继承 visibility 属性的值  visibile:默认值,元素是可见的: hidden: 元素是不可见的[即使元素的 visibility 值为 hidden,也会占据页面上的空间] <html> <head> <style type="text/css"> h1.visible {visibility:hidden} h1.invisible {

range()函数常和len()函数一起用于字符串索引。在这里我们要显示每一个元素及其索引值。

print(foo[不能是空,不能是字母如a或‘a’,可以是0,1,2]) 去了print,foo[i或数字]输出'a''b''c'(带引号) foo='abc'

使块元素并排显示和清除浮动的方法

使多个块元素并排显示: ①inline-block:内敛块,不占一行,但可以设置宽高属性,将块元素的display设置为inline-block,可以让多个div块横向显示.但是该用法下多个块之间会出现空格,是由于相邻两个</div>与<div>之间的换行符引起的,空格的清除办法: ①去掉换行符(不推荐):页面不美观 ②注释(不推荐):将换行部分注释掉 ③将上一行的>移到下一行(不推荐):页面不美观 ④将要并排显示的div添加父元素,并且给父元素div添加属性:font-si

[ jquery 效果 show([speed,[easing],[fn]]) hide([speed,[easing],[fn]]) ] 此方法用于显示隐藏的被选元素:show() 适用于通过 jQuery 方法和 CSS 中 display:none type=&#39;hidden&#39; 隐藏的元素(不适用于通过 visibility:hidden 隐藏的元素)

show()显示隐藏的被选元素:show() 适用于通过 jQuery 方法和 CSS 中 display:none type='hidden' 隐藏的元素(不适用于通过 visibility:hidden 隐藏的元素): hide() 方法隐藏被选元素: 参数 描述 speed 可选.规定显示效果的速度. 可能的值: 毫秒 "slow" "fast" easing 可选.规定在动画的不同点上元素的速度.默认值为 "swing". 可能的值: &

JavaScript - 元素的显示和隐藏

元素的显示和隐藏 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>元素的显示和隐藏</title> <style type="text/css"> img{ display:block; } </style> <script type="text/