Java程序辅导

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

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
COMP3200 Anonymous Questions and Answers Page (2021, 783-802) 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 802: Submission reference: IN2040 is this correct for presents for postcode code deleted Answer 802: That looks right. Question 801: Submission reference: IN2039 Hope you have a good break as well! Answer 801: Thanks! Still lots of marking to do for the in-class assessment, though! Question 800: Submission reference: IN2038 hi sir how would i go about making the code for presents for postcode work this is what i have so far but i get int cannot be referenced from non static method or something like that. public int presentsForPostcode(String fullPostcode) { if (fullPostcode.equals(Address.getPostcode())) return -1; } Answer 800: I think you need to spend some time thinking about the logic that will be required to solve this problem before you start to write the code. For instance. Will you need to perform a search of some sort or will you be able to do a direct lookup in something like a list or a map? Will you need to iterate over multiple objects, and so on. Then make sure that each piece of code you write makes logical sense and is valid Java. For instance, in the code you have submitted, Address.getPostcode() is not valid and nothing in the body of the method actually fits with what the method is trying to do. While I don't mind answering questions about the assignment, it isn't really practical for me to comment on lots of pieces of code that don't really make much sense. Keywords: method-presentsForPostcode Question 799: Submission reference: IN2037 sir is this good for the first 2 methods code deleted Answer 799: Yes, that looks right. Question 798: Submission reference: IN2036 Hi sir for the inventory class am I using a hashmap or a array list? Answer 798: That's for you to decide which (if either) would be the most appropriate to provide the necessary functionality. Question 797: Submission reference: IN2035 hi sir is this good for the 1st method code deleted Answer 797: No, because you are only putting the value of the parameter into the map and not increasing the value that might have been there previously. Question 796: Submission reference: IN2034 Hi Sir, could you let me know if I am on the right track here? code deleted Answer 796: Yes, that is the right idea. However, if you have a key for a map then you don't need a loop to find the associated value. Just use one of the get methods. Keywords: method-addToInventory Question 795: Submission reference: IN2033 sir i am trying to do the accumilation call to the add to inventory method i have tried this so far but i get an error int cannot be defrefenced i dont know how to get around this code deleted Answer 795: It is only collection objects that have Iterators. I think it would be good to try to express in natural language how this method should work, and then aim to turn it into code to achieve that. For instance, here is one way to express the task: Find the number of presents currently recorded for the given address. Calculate the new total by adding the parameter's value to the current number. Update the number of presents currently recorded for the given address with the new total. Keywords: method-addToInventory Referrers: Question 833 (2021) , Question 877 (2021) , Question 894 (2021) , Question 907 (2021) , Question 909 (2021) , Question 909 (2021) , Question 913 (2021) , Question 922 (2021) , Question 929 (2021) , Question 930 (2021) , Question 932 (2021) , Question 938 (2021) , Question 971 (2021) , Question 973 (2021) Question 794: Submission reference: IN2032 Have you seen the new Log4J Exploit? Any chance to have a look at it yet? I replicated it on my own system using Kali and a local minecraft java edition server :) Answer 794: I did read about it but didn't try to reproduce it. It's clearly very serious. I use Log4J in some of my off-web software. Question 793: Submission reference: IN2031 Can we have more lectures with the lights turned down/off, please? I found that it was a lot easier to read what was on the screen today when you turned the lights off towards the end :) Answer 793: That is useful feedback. I will play around with the lighting today to see what works best. Question 792: Submission reference: IN2030 hi sir i am still struggling with why my code is not adding each time the method is called what i believe my code should be doing is adding the results of the presents parameters together. code deleted Answer 792: It is because you are ignoring any existing value that might already be stored at the same address, and just overwriting it with the next value. Keywords: method-addToInventory Question 791: Submission reference: IN2029 Hi Sir, could you let me know if this is correct so far? code deleted Answer 791: It won't increase the total number of presents for a single address if multiple calls are made to the method with the same address. Keywords: method-addToInventory Question 790: Submission reference: IN2028 Having created test objects with same postcode, this method has not returned the overall total number of "presents". Why is that? code deleted Answer 790: Presumably the values associated with each Address are incorrect, in that case, because your logic looks ok for presentsForPostcode. Question 789: Submission reference: IN2027 hello again, changed my code to this, code deleted Answer 789: It doesn't make sense to compare max against the length of the array. Keywords: ex-7-15 Question 788: Submission reference: IN2026 hello sir, do you mind telling me helping me out with exer7.15, this is my code so far, code deleted Answer 788: In the loop's condition, you should use the loop variable (hour) rather than max. Then, in the body of the loop you need to be comparing the current array element with the max found so far and update the max if necessary. Keywords: ex-7-15 Question 787: Submission reference: IN2025 Will we be getting a test class for assignment 5? Answer 787: See Question 737 (2021). The current assignment is number 3. Question 786: Submission reference: IN2021 For a person who is a Santa denier, you set one hell of an assignment related to him :( Answer 786: Thanks :) Question 785: Submission reference: IN2023 hi sir, do you mind telling me if this is right for exer7.13 code deleted Answer 785: Yes, that is correct. Keywords: ex-7-13 Question 784: Submission reference: IN2022 Question 781 (2021), if I put [90] wouldn't that store 89 String objects? or the "(n-1)size" doesn't apply in this scenario? Answer 784: The number in the brackets says how many things you want to store, and the will be numbered from zero to (n-1). So 90 means 90 locations numbered 0 to 89 (inclusive). Question 783: Submission reference: IN2020 How do you make your hot chocolate? I have mine full milk, 4 spoons of powder and 1 spoon of honey. Answer 783: Wow, that is super-sweet: not good for your health! Semi-skimmed, 1 of chocolate and 1 of cocoa. 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.