通过JAVA程序测试闰年
首先简要介绍一下公历上规定的闰年:四年一闰,百年不闰,四百年再闰。
针对这一规则,简要的设计部分测试用例:

附(测试截图):



以下为该程序代码段:
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage; public class Sfw_test extends Application{
AnchorPane root = new AnchorPane();
Scene scene = new Scene(root, , ); public static void main(String[] args) {
Application.launch(args);
} public void start(Stage stage){
stage.setTitle("Leapyear Testing"); Text textTitle = new Text();
textTitle.setText("LEAPYEAR TEST");
textTitle.setFont(Font.font ("BLACK", ));
AnchorPane.setTopAnchor(textTitle, 10.0);
AnchorPane.setLeftAnchor(textTitle, 10.0); Text text = new Text();
text.setText("Enter the year for testing:");
text.setFont(Font.font ("BLACK", ));
AnchorPane.setTopAnchor(text, 90.0);
AnchorPane.setLeftAnchor(text, 10.0); final TextField textField = new TextField ();
textField.setPrefWidth();
textField.getText();
AnchorPane.setTopAnchor(textField, 90.0);
AnchorPane.setLeftAnchor(textField, 330.0); final Label label1 = new Label("This area is use for show the result…");
label1.setFont(Font.font ("BLACK", ));
AnchorPane.setTopAnchor(label1, 200.0);
AnchorPane.setLeftAnchor(label1, 10.0); Button submit = new Button();
submit.setText(" Submit ");
AnchorPane.setTopAnchor(submit, 130.0);
AnchorPane.setLeftAnchor(submit, 330.0); Button clear = new Button();
clear.setText(" Clear ");
AnchorPane.setTopAnchor(clear, 130.0);
AnchorPane.setLeftAnchor(clear, 420.0); submit.setOnAction(new EventHandler<ActionEvent>() { @Override
public void handle(ActionEvent e) {
String year = textField.getText().toString();
boolean inputlegal = false;
int Isleapyear = ;
for (int i=; i<year.length(); i++) {
if (year.indexOf(year.charAt(i)) == -) {
inputlegal = false;
}
} if (Double.valueOf(year)%!=) {
Isleapyear = ;
}
else if(Double.valueOf(year)%== && Double.valueOf(year)%==){
Isleapyear = ;
}
else{
Isleapyear = ;
} if(Isleapyear == ){
label1.setText(textField.getText() + " is not a leap year");
}
else if(Isleapyear == ){
label1.setText(textField.getText() + " is a leap year");
}
} }); clear.setOnAction(new EventHandler<ActionEvent>() { @Override
public void handle(ActionEvent e) {
textField.clear();
label1.setText("This area is use for show the result…");
}
}); root.getChildren().addAll(textTitle,text,textField,submit,clear,label1);
stage.setResizable(false);
stage.setScene(scene);
stage.show();
}
}
通过JAVA程序测试闰年的更多相关文章
- 第一次java程序测试感受
第一次JAVA程序设计测试,检验了一个暑假的成果.显而易见,我做的并不是很好,程序最起码的输入输出以及方法的定义还是没有问题的,但是考到了文件输入输出便看出来了.对于文件的输入输出,虽然我预习到那里, ...
- JAVA程序测试感受
上周四下午,我们进行了JAVA测试,心里很慌,在家中只是学习了JAVA程序的输入.输出以及各种数据类型使用而已,王建民老师给我们发了一份JAVA的课前测试样卷,是关于学生信息管理系统的,我们提前从学长 ...
- JAVA程序测试时用到的与内存测试有关的东西
1.JVM启动参数 垃圾回收器调用情况参数,使用如下参数可以看到程序何时启动GC进行垃圾回收,和垃圾回收的详细信息. java Test -XX:+PrintGCDetails -XX:+PrintG ...
- Java 程序测试_循环语句中的break和continue
package test; public class Loop_Statement { public static void main(String [] args) { String[] newba ...
- Java 程序测试_判断语句
package test; public class Condition_Phase { public static void main (String[] args) { //The Traditi ...
- Java程序单元测试工具对比——Parasoft Jtest与Junit
Web应用程序开发中,面向对象的Java语言占了不少的比重.对于Java应用程序的测试方法或方式多种多样,比较典型的是程序员自己来完成程序测试中的一个部分——单元测试. 之前,慧都资讯提到单元测试是程 ...
- Junity测试最大子数列和的Java程序
1.Java环境的安装与配置: Jdk的安装: Jdk下载链接:http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-13 ...
- java并发编程(5)并发程序测试
并发程序测试 一.正确性测试 如:对一个自定义缓存的测试 //自定义的缓存 public class SemaphoreBoundedBuffer <E> { private final ...
- Java 程序优化 (读书笔记)
--From : JAVA程序性能优化 (葛一鸣,清华大学出版社,2012/10第一版) 1. java性能调优概述 1.1 性能概述 程序性能: 执行速度,内存分配,启动时间, 负载承受能力. 性能 ...
随机推荐
- HDOJ 1009. Fat Mouse' Trade 贪心 结构体排序
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Java的JDBC操作
Java的JDBC操作 [TOC] 1.JDBC入门 1.1.什么是JDBC JDBC从物理结构上来说就是java语言访问数据库的一套接口集合,本质上是java语言根数据库之间的协议.JDBC提供一组 ...
- WebStorm
1,简介 WebStorm 10是一款强大的HTML5编辑工具,是 JetBrains 推出的一款商业的 JavaScript 开发工具.功能强大的前端专用IDE,拥有即时编辑(chrome).自动完 ...
- 解读ASP.NET 5 & MVC6系列(14):View Component
在之前的MVC中,我们经常需要类似一种小部件的功能,通常我们都是使用Partial View来实现,因为MVC中没有类似Web Forms中的WebControl的功能.但在MVC6中,这一功能得到了 ...
- [LeetCode] Reverse Vowels of a String 翻转字符串中的元音字母
Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Giv ...
- modelsim实用教程--前言
前言 Modelsim是一款专业的仿真软件,特别是在Quartus II 11.0之后的版本,都没有配套自身的仿真软件,所以Modelsim成了在FPGA设计流程中的进行功能仿真的首选仿真软件之一. ...
- R - MQ
1. rabbit MQ 安装 Rabbit MQ 是建立在强大的Erlang OTP平台上,因此安装Rabbit MQ的前提是安装Erlang.通过下面两个连接下载安装3.2.3 版本: 下载并安装 ...
- flask-- 基础篇
flask简介: flask是一轻量级的web应用框架,它的实现是一个 wsgi 的微("Micro")框架,当然微("Micro")也不意味这它的功能存在不足 ...
- java编码
/** * @Comments:default:ISO-8859-1 -> UTF-8 乱码则转码 * @param: str(乱码字符),coding(default:ISO- ...
- ubuntu10.04编译安装LAMP
ubuntu10.04编译安装LAMP以及简单wordpress的使用 : http://linuxme.blog.51cto.com/1850814/971631 一.源码安装LAMP 网上有一堆关 ...