COMP3200 Anonymous Questions and Answers Page (2021, 10-29) 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 29: Submission reference: IN1169 Hi sir, do you need to answer some of the exercise questions on a word document/paper? Thanks. Answer 29: Yes, some of there are just written answers, or snippets of code that it isn't worth creating a whole BlueJ project for. Keywords: class-exercises Question 28: Submission reference: IN1168 How do you create a field? Answer 28: Here are some examples of fields:
private int price;
private String name;
private boolean isAStudent;
private double interestRate;
private Circle sun;
There are four elements to the definition of a field: Its visibility - typically private. Its type: int, String, boolean, double, Circle, etc. Its name: something that describes the field's purpose; A semicolon. Keywords: field Question 27: Submission reference: IN1167 When do you know when to use the 'void' command in programming? What do the 'set' and 'get' commands do in the program when coding for a scenario and could you give me an example please? Answer 27: void is used as the return type of a method when the method is not going to return a value to the caller of the method. For instance, the insertMoney method of TicketMachine receives an amount and updates the balance but doesn't pass back any information to the caller, whereas the getPrice method (with an int return type) explicitly passes back the integer value that is the price of a ticket. Here is a simple scenario for setting a thermostat if its current setting is below 15 degrees:
int currentSetting = thermostat.getTemperature();
if(currentSetting < 15) {
thermostat.setTemperature(15);
}
Keywords: void Referrers: Question 30 (2021) Question 26: Submission reference: IN1166 How would you go about adding optional parameters for a method? Answer 26: That feature isn't available in Java. The closest you get is varargs. Keywords: optional-parameters Question 25: Submission reference: IN1165 Can we attend drop-in sessions through Teams, for those us studying remotely? Answer 25: Unfortunately, the session is not set up for remote access. This anonymous page, or email to me, are probably the best way to get help if you are studying remotely. I will do my best to monitor both regularly. Keywords: drop-in Question 24: Submission reference: IN1164 Hi Sir, What exactly does delta mean in the method for the slowMoveHorizontal in the Circle class Answer 24: In general, the term delta means a small amount. So the parameter name has been chosen to reflect that the value is being used to adjust by a small amount rather than overwrite the current value. Question 23: Submission reference: IN1163 When calling for the method moveVertical, if you want it to move down, the integer will be positive, why is that, shouldn't it be negative? thanks Answer 23: The effect of the parameter is based on the fact that (0,0) is actually the top-left corner of the canvas rather than the bottom left. Keywords: method-moveVertical Question 22: Submission reference: IN1162 Hi sir in my assignment code I have returned the value of name, votes and judges but when the values are returned there are no spaces in between and it is all bunched up really close I was wondering if there is a way of doing this. Answer 22: You can use spaces in the strings that go in between those elements to add the necessary padding. For instance:
4 + "is greater than" + 3
would become 4isgreaterthan3 but
4 + " is greater than " + 3
would become 4 isgreaterthan 3 Keywords: assign1 , string-concatenation Question 21: Submission reference: IN1161 how can i do the slowMoveVertical and a slowMoveHorizontal both happening at the samw time? Answer 21: You can't, unfortunately, because of the way the shapes classes have been written. Question 20: Submission reference: IN1160 is there a section we can find the solutions to the exercises? Answer 20: No, but you can ask your class supervisor to check what you have done. Question 19: Submission reference: IN1159 A quick question on the new set of exercises, once we complete up to 2.41, do we send you the blueJ file by the end of the week? When would it be due in? -Many Thanks Answer 19: You don't send the exercises to me. As noted at the beginning of the exercises document: "As part of the assessment for this course, you will be asked to demonstrate to your class supervisor that you have completed a selection of the exercises in each class." So, you will do that as part of your attendance at the class this week. Keywords: class-exercises Question 18: Submission reference: IN1158 For this course is the theory aspect important to know? for example definitions, names etc. Or is it okay if we just focus on the practical aspect like writing the actual code and doing project on BlueJay? Answer 18: While the primary emphasis is on practical coding, it is necessary to understand technical terminology of programming in general, object-oriented programming and Java because knowing that helps you to understand what someone is talking about. For instance, if I am referring to mutator methods then understanding what a mutator is, what that means in terms of practical code, and the significance for a class or its objects is necessary to fully appreciate what is being said. Keywords: theory , practice , terminology Question 17: Submission reference: IN1157 Hi Sir, I was noticing some of the sources codes and wanted to ask why some fields will have the capital letter midway eg, isVisible, how the "v" is capital. also, how would we know which fields to put the capital letter. Answer 17: There is an informal rule following by Java programmers that class names start with an upper-case letter - e.g., Circle, String, TicketMachine - but variable and method names start with a lower-case letter - e.g., makeVisible, toUpperCase. Where the name of a class, variable or method is composed of multiple 'words' then the convention is to use 'camel case' - in other words, use an upper-case letter for the first letter of the second, third, fourth, etc. word but keep the other characters lower-case (the idea is that the upper-case letters look like a camel's humps). This convention makes it much easier to read a name than if everything were to be the same case. For instance, compare reading: thisIsAVeryLongNameInCamelCase versus thisisaverylongnameincamelcase. That is why we write isVisible rather than isvisible. Keywords: camel-case Question 16: Submission reference: IN1156 When making a Java source code, is it a must to have the construstor info, if not, why? because it technically gives "existence" to the object. Answer 16: Java does not require you to write a constructor and, if you don't, it provides one `behind the scenes' as a default. The default one doesn't take any parameters and doesn't have any statements in its body, but sometimes that isn't a problem as any initialisation has been done in some other way. In the code that Michael and I have written, we tend to write constructors even if they have no functionality in them because it makes that fact explicit rather than suggesting that we might have forgotten to write them. Question 15: Submission reference: IN1155 What is your Email Answer 15: It is in the Message of the Day area of the Moodle page. Question 14: Submission reference: IN1154 Hi sir thank you for answering the question so quickly. Unfourtunately i tried using (Graphics g) and paint methods, those are not as good as canvas.draw however. Is there any way that you could give us the Ship code you showed us? Answer 14: If you email me I will let you have a copy to play with. Keywords: Ship Question 13: Submission reference: IN1153 Hi Sir, how did you draw a line in the ship code on canvas, i can draw every shape, but regular lines are hard to find solutions to. Answer 13: The Ship project isn't part of the standard materials that go with the course text book. It is a separate example I put together for this course. If you want to be ambitious and have a go at adding further features to the figures project then the place to start is the Canvas class, which is responsible for doing all the drawing of the picture elements. In several methods in the Canvas class use is made of a Graphics or Graphics2D object - typically called graphic. That object has a method called drawLine that takes 4 integer parameters: startX, startY, endX, endY and draws a line between those two points. For instance:
graphic.drawLine(10, 10, 20, 20);
would draw a diagonal line from (10, 10) to (20, 20). Just bear in mind that doing something like this would be way ahead of where we are in the course at the moment but don't let that stop you if you feel like having a go! Keywords: Ship Question 12: Submission reference: IN1152 Hello Sir it does not allow my university computer to map to raptor could you help me please? Answer 12: Are you able to provide any further information, such as a screenshot of what you see when you try to do that? You could use a site like pastebin to host an image and post an anonymous link, or you could send me a screenshot via email. There will also be a chance to sort this in your COMP3200 class this week. That is one of the things the class can be used for. Keywords: raptor Question 11: Submission reference: IN1150 Hi how do we set up raptor on Mac? Answer 11: If you are not connected directly to the network, you will need to connect via the University's VPN. The use Cmd-K in a Finder window to connect to raptor as a Server. You will need to use your University login details when making the connection. Keywords: VPN , raptor Question 10: Submission reference: IN1149 What’s the best laptop I should get for this course? Answer 10: I cannot really offer an opinion on that because it depends on too many factors - primarily your particular budget. For COMP3200, BlueJ runs on Windows, Linux and MacOS so you are not restricted in choice of operating system. This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. Last modified Mon Nov 22 07:29:43 2021 This document is maintained by David Barnes, to whom any comments and corrections should be addressed.