Object-oriented second paragraph industry summary

After these three assignments, the teacher taught us how to design a multi-threaded program. These three assignments are all about multi-threading.

The 5th job - multi-threaded elevator

I couldn't make it in time for the 5th assignment, because I didn't do the previous assignment, so I couldn't do the fifth assignment.

My basic design is like this: input, scheduler, three elevators, a total of 5 threads. The input and the general scheduler obtain requests from the shared object—request queue—and send requests from the scheduler to the three elevator systems. One elevator system is the 1 scheduler of the third job that is inherited and can process and send to the elevators by itself. A series of requests from the system.

 

Job 6 - IFTT thread

I haven't completed the entire code in this assignment, I only completed a part of the code, and the code is still basically designed, and its functions have not yet been designed

My basic design is this: each monitoring job has one thread, and the threads do not interact with each other. Every time the user enters, the system accesses the user's request and the system performs the task requested by the user.

My program has only 6 threads, but I only design one class, and this code has not been completed, because I am still a little vague about its function and how to design it. my code is like this

trigger.java

package monitoring;
//ALL FILE IS FROM USER INPUT
import java.io.File;
import java.text.SimpleDateFormat;
import java.io.IOException;

public class trigger
{
public void renamed()
{
//File oldfile =new File("oldfile.txt"); //file from user input
//File newfile =new File(""); /*from user input*/


if(oldfile.renameTo(newfile)){
return 1;
}
else{
System.out.println("Rename failed");
}
}

public void modified()
{
//File file = new File("c:\\logfile.log"); //file from user input

System.out.println("Before Format : " + file.lastModified());

SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");

System.out.println("After Format : " + sdf.format(file.lastModified()));
}


public void path_changed()
{
try
{
//String filename = "newFile.txt"; //file fromo user input
String workingDirectory = System.getProperty("user.dir");

//****************//

String absoluteFilePath = "";

//absoluteFilePath = workingDirectory + System.getProperty("file.separator") + filename;
absoluteFilePath = workingDirectory + File.separator + filename;

System.out.println("Final filepath : " + absoluteFilePath);

//****************//

File file = new File(absoluteFilePath);

if (file.createNewFile()) {
System.out.println("File is created!");
}
else {
System.out.println("File is already existed!");
}

}
catch (IOException e)
{
e.printStackTrace();
}
}


public void size_changed()
{
//File file =new File("c:\\java_xml_logo.jpg"); //from useer input

if(file.exists())
{

double bytes = file.length();
double kilobytes = (bytes / 1024);
//double megabytes = (kilobytes / 1024);

System.out.println("bytes : " + bytes);
System.out.println("kilobytes : " + kilobytes);
//System.out.println("megabytes : " + megabytes);

}
else
{
System.out.println("File does not exists!");
}

}
}

 

Assignment 7 - Rental Car Request System

I didn't finish the whole program in this assignment, because I am still a little vague about this assignment, especially the various functions of the JAVA language.

My basic design is this: main thread, 100 taxis, one thread per request. I designed the Input Handler, and the Output Handler calls the input/output processing method. Every time a request queue is added to the input, a request processing thread is started. All request processing threads share 100 taxis and can obtain their status at any time.

In this assignment, I only designed the basic function of the output and I haven't modified this yet.

OutputHandler.java

package taxisystem;

import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class InputHandler {
//Scanner
public void input(String str) {
String pattern = "[cr,src,dst]";
System.out.println(pattern);

Scanner scan = new Scanner(System.in);
while(scan.hasNext()){
String str1 = scan.nextLine();
input(str1);
}
}
}

I'm so sorry I didn't do the finished program for this assignment, because I'm still learning Java and it's often vague when analyzing.

 

heart experience

After these three homework assignments, I was not very satisfied with my performance, because I could not complete the procedures for these three homework assignments, but did not complete the homework requirements. My program is considered a big BUG and not a program.

I myself hope that I will design an OO program better in the next assignment. For me, this assignment is to train my own programming ability, and I will work harder to complete the next assignment. After these three assignments, I learned a lot of OO concepts such as thread safety, OO programming, etc. Hopefully I will learn more from the next assignment.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325239875&siteId=291194637