Friday, August 30, 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(ââ¬Å"
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.