5. This weeks programming task will cover concepts required by Assignment 2. You should aim to get the help of your tutors and make further revisions.Coding exercise steps (Hint: Need help? Ask your tutor via CanvasDiscussionsIIE06):Complete the 04/Jan/2021 solution first as this extends upon that work. Next follow CanvasModulesWeek 6 where the topics of creating non-static methods is explained. Your tutors will provide further explanations on these general topics and how they relate to this IIE during their weekly tutor chats.a) Your IIE05 solution as developed during 4/Jan/2020 is given at the end of this document for ease of reference. It takes the following overall layout:public class PleaseRenameMe { public static void main(String[] args) {GTerm gt = new GTerm(600, 400);// Rest of code}}Make a copy of the IIE05 solution that uses GTerm and rename it to IIE06 and refactor your code to fit the following structure:// The instructions in the comments must be followed when for all programs in Intro To Programming assessments from now on.public class PleaseRenameMe {// The following are object member variable declarations.// All declarations at this level must be explicitly private and must not mention static.// There should be no = (equals) signs here here. private GTerm gt;// The following is the constructor method public PleaseRenameMe() {// Object member variable declarations must be initialised before doing anything else.// Any reference to an object member variable must always start with this. this.gt = new GTerm(600, 400);// Rest of code (remember to start with this. when referring to object member variables)}public static void main(String[] args) {PleaseRenameMe prmObj=new PleaseRenameMe();}} |
Run the code and test it. It should look as it did in IIE05. i.e. there should be no difference to the end-user. Are you stuck? Please ask your |
Access issues: For non-programming technical issues (relating to infrastructure, passwords, etc.) please call the RMIT IT Service and Support Centre for quick help on 03-9925 8888 and remember to ask for a reference number and pass it on to your instructor.
Extensions: For all new extensions, a pply for special consideration online . Contacting your tutors, instructors first will lead to delays.
Please follow/complete all steps below in the given sequence:
- Check your official @student.rmit.edu.au e mail account for announcements and other communication from the university. If getting in touch with your instructors, please only use this account (not Canvas inbox, messages, personal email, phone, Microsoft Teams, etc.)
- Watch any unwatched recordings of the Weekly Live Lecture and complete all missed tutorials before going further. For your convenience, the time stamps of recordings are sent via student email/CanvasAnnouncements.
- Is there something that you have not fully grasped from what has been covered so far? Please have your doubts clarified via one of the relevant forums under CanvasDiscussions. Leaving gaps has shown to be severely detrimental to learning.
- Did you want to make any additions to the previous IIE? Please do by replying to your original post. i.e. do not edit, change the images of existing posts as it affects submission timing.
friendly tutor by creating a post in the relevant IIE forum.b. Move all of your array declarations (you need to include all of them) and variable declarations that correspond with currentNumStudents and maxNumStudents (refer to IIE05 solution) to the object member variable level (ensure that they are named to suit your program). Also ensure that they follow the guidelines given in the 5as comments. The array creation and variable initialisations should still be inside the constructor. Ensure that, when a method refers to an object member variable (or array), it starts with this. (this dot) at all times. Run the program and ensure that it works. Are you stuck? Please ask your friendly tutor by creating a post in the relevant IIE forum.c. Create the following method (it must be at the same level as the other methods, not inside any other methods):public void refreshTable() {// 1. Clear the rows of the table.// 2. Loop through the arrays and add each record to the table}Implement the steps in the above methods comments. You will need to make the loop (step 2) repeat from 0 to currentNumStudents. Are you stuck? Please ask your friendly tutor by creating a post in the relevant IIE forum.d. Next, modify your old code (which should still be in the constructor) so that it does not invoke/use the .addRowToTable method. Instead, it calls the refreshTable method when it needs to display values in the table. Are you stuck? Please ask your friendly tutor by creating a post in the relevant IIE forum.e. After the statement that adds the table, add the following statement:this.gt.addButton(Add, this, addRecord);Run the program and verify that there is a button named Add.Now implement the following method (it must be at the same level as the other methods, not inside any other methods):public void addRecord() {// 1. Take comma separated inputs of a record// 2. Split the input// 3. Add the split input in to the array, increment currentNumRecords// 4. Call refreshTable}After implementing the above (and its comments), you may want to remove the loop-based record adding code from the IIE05 solution.i.e. now, when the user wants to add one record, they will select the add button. Are you stuck? Please ask your friendly tutor by creating a post in the relevant IIE forum.f. Investigative exercise: With the help of your tutor, investigate in the GTerm documentation (Javadoc) for a suitable method to add a text field (or several). Modify your addRecord code so that it takes what is in the text field, instead of using .getInputString. Are you stuck? Please ask your friendly tutor by creating a post in the relevant IIE forum.g. Create a copy of the above IIE06 project and name it IIE06C. Make this version use Scanners .nextLine + System.in for inputs and System.out for outputs (GTerm, JoptionPane, etc. should not be mentioned). It should provide all of the functionality that the GTerm version allowed. |
Reviews
There are no reviews yet.