Skip to content
Snippets Groups Projects
Commit 8ce33625 authored by Ko Himson's avatar Ko Himson
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
Pipeline #55435 failed
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Workshop 7.iml" filepath="$PROJECT_DIR$/Workshop 7.iml" />
</modules>
</component>
</project>
\ No newline at end of file
ABC 0 → 100644
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
File added
File added
File added
File added
File added
File added
import java.io.BufferedWriter;
import java.io.IOException;
public class Car implements FileWriteable{
private String model;
private String colour;
public void writeToFile(BufferedWriter writer) throws IOException {
}
}
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public class Database {
private FileWriteable[] object=new FileWriteable[100];
private static int numobject=0;
public Database() {
}
public void addobject(FileWriteable input){
object[numobject++]=input;
}
public void removeobject(FileWriteable input){
for (int n=0;n<numobject;n++){
if (object[n].equals(input)){
for (int j=n;j<numobject;j++){
object[j]=object[j+1];
}
}
}
numobject--;
}
public void writeAll(String filename) throws IOException {
BufferedWriter bw =
new BufferedWriter(new FileWriter(filename));
for (int n=0;n<numobject;n++){
object[n].writeToFile(bw);
}
}
public static void main(String[] args) throws IOException {
Point pointa=new Point(2.1,2.3);
Database data=new Database();
data.addobject(pointa);
data.writeAll("ABC.txt");
}
}
import java.io.BufferedWriter;
import java.io.IOException;
public interface FileWriteable {
void writeToFile(BufferedWriter writer) throws IOException;
}
import java.io.BufferedWriter;
import java.io.IOException;
public class Point implements FileWriteable{
private double x;
private double y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public void writeToFile(BufferedWriter writer) throws IOException {
}
}
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.Objects;
public class Student implements FileWriteable {
private int id;
private String name;
public void writeToFile(BufferedWriter writer) throws IOException {
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment