init commit

This commit is contained in:
m-mun
2026-09-03 09:09:11 +09:00
parent 7e0caa5ac3
commit f22760db5c
180 changed files with 34706 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
public class Library {
private String name;
private String postNumber;
private String address;
private String tel;
public Library(String name, String postNumber, String address, String tel) {
this.name = name;
this.postNumber = postNumber;
this.address = address;
this.tel = tel;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPostNumber() {
return postNumber;
}
public void setPostNumber(String postNumber) {
this.postNumber = postNumber;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("名前:" + this.name + "\n");
sb.append("郵便番号:" + this.postNumber + "\n");
sb.append("住所:" + this.address + "\n");
sb.append("電話番号:" + this.tel + "\n");
return sb.toString();
}
}

View File

@@ -0,0 +1,44 @@
import java.io.IOException;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
/*
* PTra24_01.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
/* TODO XmlDataクラスを作成してください。
* ※PTra24_01、XmlConnection、Libraryクラスは変更しないでください
*
* */
public class PTra24_01 {
public static void main(String[] args) {
System.out.println("図書館を表示したい区を入力してください。(例:新宿区)");
String ward = inputString();
try {
XmlConnection xmlCon = new XmlConnection("xml/tokyoLibraryList.xml");
Document doc;
doc = xmlCon.getConnection();
XmlData xmlData = new XmlData(ward);
List<Library> list = xmlData.getXmlToListData(doc);
for (Library lib : list) {
System.out.println(lib);
}
} catch (SAXException | IOException | ParserConfigurationException e) {
e.printStackTrace();
}
}
public static String inputString() {
java.util.Scanner scanner = new java.util.Scanner(System.in);
String str = scanner.nextLine();
return str;
}
}

View File

@@ -0,0 +1,24 @@
import java.io.IOException;
import java.nio.file.Paths;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
public class XmlConnection {
private String filePath;
public XmlConnection(String filePath) {
this.filePath = filePath;
}
public Document getConnection() throws SAXException, IOException, ParserConfigurationException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(Paths.get(this.filePath).toFile());
return document;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff