Java程序辅导

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

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
COMP3200 Anonymous Questions and Answers Page (2021, 523-542) XML COMP3200 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 542: Submission reference: IN1723 hi sir i am struggling with exercise 6yy this is what i got so far i dont know what it is meant to return i can see what it says it wants but i dont know how to go about it code deleted Answer 542: Do bear in mind that we haven't covered this in the lectures, yet, so it would be worth reading the material in Chapter 6 if you want to have a go at it at this stage. Since the method has to return a String, that needs to be part of the method header and, as you can see from the example in the execise description, the method should only have one parameter. Keywords: ex-6-yy Question 541: Submission reference: IN1721 hi sir does this look good for the throw dice method code deleted Answer 541: Yes, but the name of the method does not match the name given in the exercise. Aim to be accurate in all your coding. Keywords: ex-6-16 Question 540: Submission reference: IN1726 Hi, is this code correct for the findTest method? public InfectionTest findTest(String id) { int index = 0; while(index < results.size()) { String test = results.get(); System.out.println(); index++; } return id; } Answer 540: No, because it doesn't actually involve any InfectionTest objects at the moment or do anything with the id parameter. You should review the slides for examples of how to search a collection for something and then adapt them to the particular context of the assignment. Keywords: method-findTest Question 539: Submission reference: IN1724 Question 527 (2021), I added to the brackets, but it says removed(at the end) is an undeclared variable code deleted Answer 539: Only method calls need parentheses like that, and removed is a variable. Keywords: method-removeUnknownStatus Question 538: Submission reference: IN1722 Im completely stuck on the setStatus method and do not know where to start. Do I use a while or for each loop? Answer 538: Either is fine. If you are so stuck that you don't know where to start then you probably need to review the material in Chapter 4 before you start, otherwise you could flail around for a long time and not get anywhere. You can only code something if you know what you are doing. Keywords: method-setStatus Question 537: Submission reference: IN1720 Question 535 (2021) again i added some brackets but am still not sure exactly what im doing wrong and what exactly the errors are coming up for? My code seems fine?? code deleted Answer 537: You are adding every test object to the collection, regardless of its status. Keywords: method-removeUnknownStatus Question 536: Submission reference: IN1719 Hi Sir, I'm stuck on how to format the setStatus method. This is what I've got so far even though it doesn't compile: code deleted Please tell me what I need to include or remove in the code. Answer 536: It doesn't make sense to compare a String (id) with a boolean value (true). You need to compare the id parameter with the ID strings of the InfectionTest objects. Also do what the description says, 'call [the matching object's] setStatus method with the value of the positive parameter' Keywords: method-setStatus Question 535: Submission reference: IN1718 Here is my code sir, It has 0 errors but 3 failures? Two tests should have been returned. ==> expected: <2> but was: <4> No tests should have been returned. ==> expected: but was: Two tests should have been returned the first time. ==> expected: <2> but was: <4> code deleted Answer 535: Rather than posting the whole of your class it would be more helpful to me if you only posted the method with the error, which you should be able to tell from the tests that do not pass. I previously noted in answer to an earlier question that there is a problem with the curly brackets (or lack of them) in the body of the loop. Try to understand what the error messages are telling you and relate that to what your method is, therefore, doing. Keywords: method-removeUnknownStatus Referrers: Question 537 (2021) Question 534: Submission reference: IN1717 Hi David I've noticed an error in my code in the find test method. My code is as follows: code deleted where the final return statement (return XXXXX) is I'm not sure what to return, as true or 0 just leads to an error saying InfectionTest cannot be converted to type boolean or int. What should I return? Answer 534: Please see my answer to Question 532 (2021). Keywords: method-findTest Question 533: Submission reference: IN1716 Hello, sir! Would you mind if you take a look at my code. It is compiling, but if I test it ,it gives me an error. Thank you! code deleted Answer 533: Please re-read what the assignment says about the isPositive method of the InfectionTest class. Keywords: method-getPositiveTests Question 532: Submission reference: IN1715 Good afternoon sir, Is this correct for the findTest method? code deleted Answer 532: No, because it doesn't do what the assignment says it should do: 'return [the found object] as the method's result'. Printing is not returning. Keywords: method-findTest Referrers: Question 534 (2021) Question 531: Submission reference: IN1714 Question 521 (2021) here: Just updated this code deleted Is it fully correct? Answer 531: It looks to be. I recommend that you test your methods with the test class. Keywords: method-getPositiveTests Question 530: Submission reference: IN1713 I made a small change code deleted Answer 530: At the end of the method, your return statement has a pair of parentheses as if a method is being called, which it isn't. You are meant to just be returning the list. PS: There is no link between one question and the next and I am answering tens of questions each hour so I rarely have any idea which previous question you might be referring to unless you tell me ;) Keywords: method-removeUnknownStatus Question 529: Submission reference: IN1712 I can't seem to add to the collection, i also arent sure of how exactlt to return the removed tests code deleted Answer 529: Your iteration and removal is fine but you aren't adding the matched InfectionTest object to the list. You add something to a collection via its add method, e.g.: collection.add(something); Keywords: method-removeUnknownStatus Question 528: Submission reference: IN1711 Hi David, I'm not sure what to do here as the parameter "id" is a string but since I can't modify the header I can't change it to InfectionTest type in order for the for each loop to run. Would I have to change my collection to a String instead of an Infection type? code deleted Answer 528: No, what you need to change is the type of the variable in the for-each loop. I also recommend renaming the loop variable from id to something like test. Keywords: method-setStatus Question 527: Submission reference: IN1710 May I please know whats wrong here? code deleted Answer 527: When you call a method, you don't include the type with the parameter. The add method requires a parameter - what is being added? Keywords: method-removeUnknownStatus Referrers: Question 539 (2021) Question 526: Submission reference: IN1709 I don't think this is right, but it seems to compile; code deleted Answer 526: A few comments: Please re-read in the assignment description what it says about the isPositive method of InfectionTest because your code is doing something that it explicitly says it must not do. I am not clear why you are calling the isEmpty method. Having created a set and added InfectionTest objects to it, you aren't doing anything with it at the end of the method. Keywords: method-getPositiveTests Question 525: Submission reference: IN1708 Question 562 (2021) here, Having read your explanation does this mean I have to call the is known first before the is positive Answer 525: Indeed. Question 524: Submission reference: IN1706 I'm getting 2 errors from the setStatus code, and 1 error and 1 failure from the HashSet code and I'm unsure why? code deleted Answer 524: Please re-read in the assignment description what the setStatus method is meant to do because your code isn't doing something that it explicitly says it must do. Please re-read in the assignment description what it says about the isPositive method of InfectionTest because your code is doing something that it explicitly says it must not do. Keywords: method-setStatus , method-getPositiveTests Question 523: Submission reference: IN1705 Sir, this code is giving me 3 fsilures, and I'm unsure why? code deleted Answer 523: When you create the new list you add all the existing tests to it, which is not correct. It should be empty to start with. Keywords: method-removeUnknownStatus This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. Last modified Wed Jan 12 11:47:56 2022 This document is maintained by David Barnes, to whom any comments and corrections should be addressed.