Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
CO5570 Anonymous Questions and Answers Page (2021, 75-94) XML CO5570 Anonymous Questions and Answers This page lists the various questions and answers. To submit a question, use the anonymous questions page. You may find the keyword index and/or top-level index useful for locating past questions and answers. We have taken the liberty of making some minor typographical corrections to some of the questions as originally put. Although most of the questions here will have been submitted anonymously, this page also serves to answer some questions of general interest to those on the course. Question 94: Submission reference: IN2453 In the example (A4) x = 100 what category does "100" go into? Answer 94: It is an INT_CONST because it consists of a sequence of one or more digits (0-9). Keywords: assign4 , INT_CONST Question 93: Submission reference: IN2449 Just to confirm with A4. The brief states that the correct suffix will always be used. does this mean it will always use an existing file so we do not have to check for the file being present? Answer 93: No, you should check that the file exists and can be read. Keywords: assign4 Question 92: Submission reference: IN2442 Hi David - if I cant get my A3 to work, should I just not bother to submit? as its marked only on functionality and not on code at all. Answer 92: Do submit because I will aim to mark as much as possible even if it is not complete. Question 91: Submission reference: IN2429 stuck on running code ive got the assemble and compile scripts working say i execute bash assemble value2.shk im stuck with it running on waiting for inputs what do i put in the assemble file? Answer 91: Why is it waiting for input when you have given it the name of the input file? That's the only input your assembler should be reading. Question 90: Submission reference: IN2427 I saw that you said that "the assembler needs to separate the name of the file from its containing folder/directory"So is an example of an argument filename.shk and we have to then find the directory/folder that it is In. Or will the file path be given as an argument, to then be separated? Answer 90: The path will be part of the filename argument. For instance, I might run: assemble ../../tests/noerrors/example1.shk or assemble /Users/djb/comp5570/assignment3/tests/noerrors/example1.shk and I will expect the .asm file to be written to the same directory as the Shack source file. Question 89: Submission reference: IN2425 does your test script have full stops at the end of error messages some of them shown do some dont Answer 89: Yes, as seen in the assessment brief. Follow the text you see there. Question 88: Submission reference: IN2423 why do we have to declare rom jump errors at the end ? my understanding is that because its forward refs we have to pass twice ? Answer 88: You don't have to pass twice. The only reason that is needed in Hack is that you can't know which are ROM and which are RAM labels until the end of the first pass and that affects the numerical resolution of the labels as well. In Shack, you do know which is which and there is no numerical resolution required. Question 87: Submission reference: IN2422 If I find and print an error for a RAM label when going through the dec section would that then count as undefined if it were to be used in the code section? Otherwise, the errors would be called in the dec section and when it appears in the code section. Answer 87: If there is an error for the declaration then the declaration isn't valid, so the variable won't have been declared. That would likely result in an undeclared error later if the variable is used. Question 86: Submission reference: IN2420 Question 83 (2021) do we have to report each time or just once when a rom label duplicates a ram label. if the label in question is used multiple times Answer 86: Usage and definition are separate issues but don't worry about pathological cases. Remember that I'm primarily interested in testing correct behaviour for correct programs. Question 85: Submission reference: IN2419 Question 82 (2021) sorry i was refering to In the unlikely case that a ROM label is duplicated and also duplicates a RAM label, the ‘more than once’ error message must come before the ‘RAM label’ error message. Answer 85: Just do what it says and don't worry about pathological cases. Question 84: Submission reference: IN2418 when reporting undefined rom labels as jump addresses do we report as we find them or all at the end? Answer 84: You can't report them as you find them because they might be forward references. Question 83: Submission reference: IN2417 do we have to report each duplicate label where rom label is defined in ram or just once Answer 83: I am afraid I don't understand the question. Can you give an example of the scenario? Referrers: Question 86 (2021) Question 82: Submission reference: IN2416 so if a label duplicates both rom and ram labels i output a more that once error for the rom and then the ram error or do i not send a ram error ? Answer 82: I am not really clear what the scenario you are describing involves, but the requirement says: If a ROM label duplicates a RAM label it must be reported as soon as it is detected in the following form: ROM label xyz has been defined as a RAM label. Referrers: Question 85 (2021) Question 81: Submission reference: IN2414 just to clarify before i submit what is correct because on the brief there is a space and in the test example asm files there isnt D = -D & D = !D OR D = - D & D = ! D Answer 81: Spaces have no significance in Hack assembly code. Question 80: Submission reference: IN2407 Hello David, for assignment 3, are you asking our program to create an .asm file with the same name as the translated .shk file within the program in the same directory? Or can we manually just create a .asm file in the directory with the same name as the .shk file and just have the program write the translations from shack to hack into the .asm file? Answer 80: The 5th bullet point under requirements says: The assembler must write the translated Hack version to a file whose name has the same prefix as the Shack source file but a �.asm� suffix. The file written to must be in the same directory/folder as the Shack source file. How you achieve that is up to you, but the safest way is to do it via the program code. If your method involves 'manual' intervention that requires me to do the same then that won't meet the requirements. I must just be able to run your program, via the assemble script you submit, without further intervention. Question 79: Submission reference: IN2400 im very confused about submission what do i need to do ? i have a single java file Answer 79: Put your Java source file in a folder/directory and the compile and assemble scripts in the folder/directory above that. Then edit the provided compile script so that it compiles your source file and edit the assemble script so that it runs your program. Submit those three files in a zip file so that when I unzip it I can then use the scripts to compile and run your code. Question 78: Submission reference: IN2397 hello David, what should we call our zip file when we submit it? Answer 78: You can call it whatever you like. Question 77: Submission reference: IN2396 hi sir, Question 76 (2021), the part where the test files will be in another directory, do we have to make it where it can find the test file in a different directory in our java code, or does the "bash assemble" do that for us? Answer 77: You will have to organise that in your source code. Question 76: Submission reference: IN2395 sorry sir, let me ask my question in another way. would you test our code to read the shk file from a directory far different from the directory of the submitted zip file? the reason I ask this is that in Question 73 (2021), you said that the shk file can be located anywhere. By that, I assumed that anywhere as in any directory, even different to the zip file. Answer 76: Yes, the test files will be in another directory. Referrers: Question 77 (2021) Question 75: Submission reference: IN2392 hello again David, I am the one who asked the question in Question 73 (2021) and now I need more clarification on something. I managed to do the part where I pull out the directory from the shack and put it into my hack as '.asm', but I am facing the problem where I can only access the shk file only when it is in the same directory as my '.java' file where I do the assembling. I know doesn't sound like a question related to the assignment, but I hope you can help me since I couldn't find a way. Answer 75: I am not completely sure of the context of the question but I assume that you mean at the Java level (assuming you are using Java). You can find out the components of a file name by creating a java.io.File object for it. That has methods such as getName and getParent. Here is an example for you to try them out with. import java.io.*; public class ShowFileComponents { public static void main(String[] args) throws Exception { for(String f : args) { File file = new File(f).getAbsoluteFile(); System.out.println("Program argument: " + f); System.out.println("Parent dir: " + file.getParent()); System.out.println("File name: " + file.getName()); } } } This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. Last modified Thu Feb 10 09:13:46 2022 This document is maintained by David Barnes, to whom any comments and corrections should be addressed.