.

Sunday, September 29, 2019

Stylistic Analysis of the Text “The Last Leaf

/* * */ package javafxgrouping; /** * * @author 094632220 */ public class StudentEntity { // private String id; private String name; private String className; public StudentEntity(){ } public StudentEntity(String aID, String aName, String className) { this. id = aID; this. name = aName; this. className = className; } public String getId() { return id; } public void setId(String id) { this. id = id; } public String getName() { return name; } public void setName(String name) { this. name = name; } public String getClassName() { return className; } public void setClassName(String className) { his. className = className; } @Override public String toString() { String str = id + â€Å",† + name + â€Å",† + className ; return str; } } /* * : TaDB. java * —————————– * HashMap HashMap id( )? * , taMap? HashMap * , (public ): * TaEntity findEntry(String id): * String findName(String id): * int rows(): * Iterator getIterator(): ( ) */ package javafxgrouping; import java. io. BufferedReader; import java. io. FileNotFoundException; import java. io. FileReader; mport java. io. IOException; import java. util. ArrayList; import java. util. HashMap; import java. util. Iterator; import java. util. Map; import java. util. StringTokenizer; /** * * @author */ public class TaDB { /* */ private Map taMap; // (HashMap) /* * TaDB, (TA. txt) * , */ public TaDB(String filename) { taMap = new HashMap(); // /* */ FileReader fr = null; try { fr = new FileReader(filename); } catch (FileNotFoundException e) { System. out. print(â€Å" † + filename + â€Å"! ); } /* */ BufferedReader bf = new BufferedReader(fr); String line; try { // while ((line = bf. readLine()) ! = null) { // , ta ArrayList ta = new ArrayList(); StringTokenizer tokenizer = new StringTokenizer(line, â€Å",†); ta. add(tokenizer. nextToken()); while (tokenizer. hasMoreTokens()) { String token = tokenizer. nextToken(); ta. add(token); } // TaEntity entry = new TaEntity(ta. get(0), ta. get(1), ta. get(2), ta. get(3), ta. get(4), ta. get(5)); // (HashMap) taMap. put(entry. getId(), entry); } } catch (IOException e) { System. ut. print(â€Å" † + filename + â€Å"! â€Å"); } } /* * id( ) , null? */ public TaEntity findEntry(String id) { return taMap. get(id); } /* * id( ) , null? */ public String findName(String id) { return taMap. get(id). getName(); } /* * */ public int rows() { return taMap. size(); } /* * (id) */ public Iterator getIterator() { return taMap. keySet(). iterator(); } } /* * */ package javafxgrouping; /** * * @author */ public class TaEntity { private String id; // private String name; // rivate String iid; // private String email; // private String phone; // private String tutor; // /* */ public TaEntity() { } /* */ public TaEntity(String aID, String aName, String aIID, String aEmail, String aPhone, String aTutor) { this. id = aID; this. name = aName; this. iid = aIID; this. email = aEmail; this. phone = aPhone; this. tutor = aTutor; } /*getter ? setter*/ public String getId() { return id; } public void setId(String ID) { this. id = ID; } public String getName() { return name; } public void setName(String name) { this. name = name; } public String getIid() { eturn iid; } public void setIid(String IID) { this. iid = IID; } public String getEmail() { return email; } public void setEmail(String email) { this. email = email; } public String getPhone() { return phone; } public void setPhone(String phone) { this. phone = phone; } public String getTutor() { return tutor; } public void setTutor(String tutor) { this. tutor = tutor; } * */ @Override public String toString() { String str = id + â€Å",† + name + â€Å",† + iid + â€Å",† + email + â€Å",† + phone + â€Å",† + tutor; return str; } } /* * */ package javafxgrouping; import java. io. FileWriter; import java. io.IOException; import java. io. PrintWriter ; import java. util. ArrayList; import java. util. Iterator; import java. util. Random; import java. util. logging. Level; import java. util. logging. Logger; import javafx. application. Application; import javafx. collections. FXCollections; import javafx. collections. ObservableList; import javafx. event. ActionEvent; import javafx. event. EventHandler; import javafx. scene. Group; import javafx. scene. Scene; import javafx. scene. control. Button; import javafx. scene. control. ListView; import javafx. scene. input. MouseEvent; import javafx. scene. text. Font; import javafx. stage.Stage; /** * * @author */ public class JavaFXGrouping extends Application { // HTML private static String htmlFileName = â€Å"group. xhtml†; // CSS private static String cssFileName = â€Å"style. css†; private final int sceneWidth = 900; // private final int sceneHeight = 660; //// private TaDB taDb = new TaDB(â€Å"src/javafxgrouping/TA. txt†); // // , private StudentsDB studen tsDb = new StudentsDB(â€Å"src/javafxgrouping/Students. txt†); private ArrayList taIdArray = new ArrayList(); // d private ArrayList studentIdArray = new ArrayList(); // id private ArrayList studentAdd = new ArrayList(); private int studentsNo = studentsDb. rows(); private int groupNo = taDb. rows(); // , private Button btn = new Button(â€Å" â€Å"); // â€Å" â€Å" private Button btn1 = new Button(â€Å" HTML â€Å"); // â€Å" HTML â€Å" private ListView[] group = new ListView[groupNo]; // , 1? rivate ObservableList[] myObservableList = new ObservableList[groupNo]; // private Group root = new Group(); // @Override public void start(final Stage primaryStage) { // â€Å" â€Å" btn. setFont(Font. font(null, 24)); btn. setLayoutX(sceneWidth – 240); btn. setLayoutY(20); btn. setPrefSize(220, 50); // â€Å" HTML â€Å" btn1. setFont(Font. font(null, 24)); btn1. setLayoutX(sceneWidth – 240); btn1. setLayoutY(20); btn1. setPrefSize(220, 50); btn1. se tVisible(false); initArray(); // taIdArray? studentIdArray drawGroupList(); // , root. getChildren(). ddAll(btn, btn1); // Scene scene = new Scene(root, sceneWidth, sceneHeight); // primaryStage. setTitle(â€Å" â€Å"); // primaryStage. setScene(scene); // primaryStage. show(); // //† â€Å" ( ) btn. setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { btn. setVisible(false); randomGrouping(); btn1. setVisible(true); } }); //† HTML â€Å" ( ) btn1. setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { writeToFile(); btn1. setVisible(false); } }); } ** * JavaFX main() IDE FX * NetBeans main() * * @ args */ public static void main(String[] args) { launch(args); } private void drawGroupList() { int k; for (int j = 0; j < groupNo; j++) { myObservableList[j] = FXCollections. observableArrayList(); group[j] = new ListView(); group[j]. setStyle(â€Å"-fx-font-size:18;†); group[j]. setItems(myObservableList [j]); group[j]. setLayoutX(20 + j * 60); group[j]. setLayoutY(20 + j * 34); group[j]. setPrefSize(360, 320); k = j + 1; myObservableList[j]. add(â€Å"? † + k + â€Å"? [ :† + taIdArray. et(j) + â€Å",† + taDb. findName(taIdArray. get(j)) + â€Å"]†); final int i = j; group[j]. setOnMouseClicked(new EventHandler() { @Override public void handle(MouseEvent event) { group[i]. toFront(); } }); root. getChildren(). add(group[j]); } } private void initArray() { // id Iterator taIterator = taDb. getIterator(); while (taIterator. hasNext()) { taIdArray. add(taIterator. next()); } // id , Iterator studentsIterator = studentsDb. getIterator(); while (studentsIterator. hasNext()) { studentIdArray. add(studentsIterator. ext()); } } private void randomGrouping() { // , int i, j, num = 0; Random studentsRandom = new Random(); for (i = 0; i < groupNo; i++) { j = 0; if (i < studentsNo % groupNo) { while (((studentsNo – num) ! = 0) && (j < studentsNo / groupNo + 1)) { j++; int studentNo = studentsRandom. nextInt(studentsNo – num); myObservableList[i]. add(studentsDb. findclassName(studentIdArray. get(studentNo)) + â€Å",† + studentIdArray. get(studentNo) + â€Å",† + studentsDb. findName(studentIdArray. get(studentNo))); studentAdd. add(studentIdArray. et(studentNo)); studentIdArray. remove(studentNo); num++; if (num == studentsNo) { break; } } } else { while (((studentsNo – num) ! = 0) && (j < studentsNo / groupNo)) { j++; int studentNo = studentsRandom. nextInt(studentsNo – num); myObservableList[i]. add(studentsDb. findclassName(studentIdArray. get(studentNo)) + â€Å",† + studentIdArray. get(studentNo) + â€Å",† + studentsDb. findName(studentIdArray. get(studentNo))); studentAdd. add(studentIdArray. get(studentNo)); studentIdArray. remove(studentNo); num++; f (num == studentsNo) { break; } } } } } private void writeToFile() { writeToHtml(htmlFileName); createCss(cssFileName); } private void writeToHtml(String fileName) { // HTML , PrintWriter wr = null; try { wr = new PrintWriter(new FileWriter(htmlFileName)); } catch (IOException ex) { Logger. getLogger(JavaFXGrouping. class. getName()). log(Level. SEVERE, null, ex); } wr. println(â€Å"

No comments:

Post a Comment