10年专注于英语国家留学生作业代写,网课代修,网课Exam代考
java代写_java代码代写_代做java作业_DueEssay论文代写

java代写_java代码代写_代做java作业

计算机作业代写 、 cs代写 ---java代写,java编程代写, java程序代写 ,java作业代写, 我们提供各种编程语言和写作服务课程,包括c / c ++,java,python,php,matlab,网站设计,前端开发,..

EG1hao 立即咨询

快速申请办理

称       呼 :
联系方式 :
备       注:

java代写_java代码代写_代做java作业

发布时间:2020-12-04 热度:

计算机作业代写cs代写---java代写,java编程代写,java程序代写,java作业代写,我们提供各种编程语言和写作服务课程,包括c / c ++,java,python,php,matlab,网站设计,前端开发,小型游戏设计,作业,实验室,考试等。
 


 
CS代写、计算机作业代写,java代写,python代写,c/c++代写

提供专属的CS程序代写、math代写、金融代写、统计代写、商科代写、economic代写服务,代写各类程序语言:C语言代写, C++代写, 算法作业代写, 数据结构代写, AI/MachineLearning代写, python代写, java代写, matlab代写, 汇编代写, scala代写, SQL/Database代写, racket代写, 安卓/Android代写, IOS/swift代写, racket代写, 网络代写, web代写, OS/操作系统代写, R代写等, 新增代写STAT, math, business代写, economic代写等,涵盖北美CS代写,  加拿大CS代写,  美国CS代写,  澳洲CS代写,  新西兰CS代写,  英国CS代写,  新加坡代写,  香港CS代写等.

You should carefully read through all the code before starting on the assignment.

Paths, Files, Reading and Writing
This assignment requires creating, reading and writing files. Your assignment project directory contains a directory “data”. This directory contains some CSV files that you should use in development and testing.

You should only read files from this directory and write files to this directory. The only files you write to should have names that start with “temp_”. The marking software will run your code in a secure sandbox environment and any attempts to read or write outside this directory or to write to a file whose name does not start with “temp_” will cause an exception to be thrown and your program to fail.
The java.nio.file.Path class represents full and partial file path strings to be handled. By default, when your program starts, it does so with your project directory as its current working directory. Therefore if you give a relative path name for a file you wish to read, e.g. “data/state-abbrevs.csv”, then it will look for that file path starting at your project directory. You will frequently want to be able to create paths to new files in the data folder:

Given a path variable dataDir to a directory, you can construct a path variable to a file given by a String
filename, “temp_copy.csv”, with: dataDir.resolve(“temp_copy.csv”)

You can also create a Path from Strings using calls like Paths.get(“data”) or Paths.get(“data”,

“temp_copy.csv”)

You can get the String name of a file (the last component of a path) with path.getFileName(). This acually returns a path with a single component, but the toString() method of Path will turn it into a string.
If you have the path of a file, and want to create the path of a new file in the same directory, you can use:
path.resolveSibling(“temp_new_file.java”)

You will need to generate names for your output files that do not clash with your input file names or any other output file names. To do this, make an output file name from the input filename in the form: if the input filename is “abc. csv”, make the output file name be “temp_00000_abc.csv”, where the number part can be incremented for each output that you need. If your input file Path in in the variable fromPath, and your temporary file number counter is in the integer variable tempNum, this can be done with:
Path tmpPath = fromPath.resolveSibling(

String.format(“temp_%05d_%s”, tempNum, fromPath.getFileName()) );

Scanner and PrintWriter

For this assignment, you should use the Scanner class for reading CSV files and the PrintWriter class for writing them. This ensures that all unicode characters are handled appropriately.

You can open a Scanner on a file specified by a Path object with:
Scanner from = new Scanner(fromPath);

The PrintWriter class does not currently support opening a file from a Path object, so you first have to turn the Path object into a File object:
PrintWriter to = new PrintWriter(toPath.toFile()))

Once you have opened a file, it is important to ensure that you close it:

Not closing it can mean that your program can crash if you open many files: there is a limit on how many files you can have open at the same time. While this limit is large, it is possible to hit the limit.
Not closing open files is a memory leak and wastes memory
Under some circumstances, not closing a file may cause some of the last writes to that file to not be saved to the file on disk
Therefore you should get in the habit of always closing your files. While you can close them directly, you have to ensure that they get closed even if an exception occurs before you make the call to close them. You can handle this with the try

… catch … finally construct, but there is a much easier and more convenient way: the try-with-resources construct:

try ( Scanner from = new Scanner(fromPath);

PrintWriter to = new PrintWriter(toPath.toFile()))

{

// do your reading and writing here – do not close

}

This form of try ensure that every resource which is constructed the “try” part is open with the following curly braces and is automatically closed when the program leaves the braces, whether that leave is caused by an exception, a return, or simply completing the code in the braces. Note that the code in the try part is a series of assignments separated by semi-colons. You can have as many as you like. You can also nest them, if you wish:

try ( Scanner from = new Scanner(fromPath) )

{

// read from “from” here

try ( PrintWriter to = new PrintWriter(toPath.toFile()) )

{

// Read from “from” and write to “to” here

}

// read from “from” here

}

Priority Queues and Comparators
A PriorityQueue is Java’s implementation of the Priority Queue data structure. To use it you need to use a Comparator object which tells the PriorityQueue how to compare the objects that you put into it. The CsvFormatter class contains a nested CsvComparator class that is suitable for this purpose. Since it is nested inside CsvFormatter, you can only create a CsvComparator object from a CsvFormatter object as follows:

CsvFormatter formatter = … // get a formatter object

String columnName = “abbreviation”; // the header of the column used for comparing CSV rows

CsvFormatter.RowComparator comparator = formatter.new RowComparator(columnName)

For this assignment, you will need to put CSV rows into it. These rows are implemented as arrays of Strings, so, given the

comparator created above, you can create a suitable new PriorityQueue as follows:

PriorityQueue<String[]> pq = new PriorityQueue<>(comparator);

Testing Arrays for Equality
Do NOT try to use the .equals method on an array of strings (i.e. a row) to check if the arrays are the same length and have the same strings: it sounds like it should work but, for good reasons, it is unlikely to do what you expect. The way to do what you want is to use Arrays.equals().

String[] row1 = … // get a CSV row

String[] row2 = … // get a CSV row

if (row1.equals(row2) // DO NOT DO THIS – IT IS VERY UNLIKELY TO DO WHAT YOU EXPECT



if (Arrays.equals(row1, row2)) // This does do what you almost certainly want



Final Instructions
The precise information about the behaviour required of the missing code is detailed in the Javadoc comments in the files.
You should modify the methods CsvUtils.getStudentId() and CsvUtils.getStudentName() in
CsvUtils.java to return your student id and name.

You should NOT add any further class variables to CsvUtils.java, or change the types or visibility of the existing class variables or methods nor modify any of the other files in the main part of the src tree.
You can add extra private methods in CsvUtils.java if you like but please note that they are not needed and my solution does not do so.
You can (and should!) modify the CsvUtilsTest.java file and you can add any other test files as you please. Your test files are for your own use and should NOT be submitted.
You should not modify the package structure or add any new classes that CsvUtils.java depends upon to run. Your final submission will be purely the CsvUtils.java file, so any modifications outside that file will not be considered and the CsvUtils.java file that you submit must work with the other files as they currently stand in the assignment structure.
You should not use any print statements to standard out or standard error streams: if you want to have some debug output, use the logging calls for Log4j. The logging system will be switched to disable log output when your submission is run for marking purposes.
For marking purposes, your code will be compiled and executed against a test set in a secure sandbox environment. Any attempts to break the security of the sandbox will cause the execution of your program to fail. This includes infinite loops in your code.
When you have completed your code changes to your satisfaction, submit your CsvUtils.java


关闭窗口
上一篇:Python代写Programming作业_Python作业代写
下一篇:代写CS编程,JAVA作业代做、代写JAVA设计编程

相关阅读


代写
微信

微信客服

微信客服:EG1hao

山东济南市历下区三庆财富中心

qq

QQ客服

QQ联系:3029629821