⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 societytest_1.java.txt

📁 the teacher resource code about the secority
💻 TXT
字号:
/*	The class to test a "simple" Society:
 *	two Persons only (initially)
 *	
 *	Author: Dmitry Gakhovich
 *	E-mail: jim_g@lycos.com  or d.gakhovich@witt.ac.nz
 *	(C) 2004
 */


import javax.swing.*;
import java.util.ArrayList;


public class SocietyTest_1{
	
	/*  To test our Society we need only main method.
	 *	This is very simple society: one male and one female, Arnold and Mary.
	 *	After they are married we get a new Person (new Object in our Society!).
	 *	It may be girl or boy.
	 *	And after we run a census second time we have plenty of new information!
	 */
	
	public static void main(String []args){
		// Create a Society and two persons:
		Society sc = new Society();
		Person m1 = new Person("Arnold", "male", 35);
		Person f1 = new Person("Mary", "female", 25);
		
		//register Persons in the Society
		sc.addPeople(m1);
		sc.addPeople(f1);
		
		// Do census first time. No inter-object references so far...
		System.out.println("\n\t**************************\n\t*\t\t\t *");
		System.out.println("\t*    C E N S U S    # 1  *");
		System.out.println("\t*\t\t\t *\n\t**************************\n");				
		sc.doCensus();	

		// Arnold and Mary are married	
		sc.weddingCeremony(m1, f1);
		// and Mary "returns" a baby, new person! - new Object!
		Person baby = f1.getBaby();
		
		// We have to name the baby (taking into account his or her gender)
		String babyGender = baby.getGender();
		if(babyGender.equals("male")){
			baby.setName("Alex");
		}
		else{
			baby.setName("Tania");	
		}
		// now have to registrate our baby :), i.e. add to the society list
		sc.addPeople(baby);
		
		// Do census second time - plenty of new information 
		// and cross-references between objects
		System.out.println("\n\t**************************\n\t*\t\t\t *");
		System.out.println("\t*    C E N S U S    # 2  *");
		System.out.println("\t*\t\t\t *\n\t**************************\n");	
		sc.doCensus();		
	}	// end main
	
}//end class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -