Java程序辅导

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

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Week 05: Homework 4 - Introductory Programming in Java Skip navigation Introductory Programming in Java ANU College of Engineering & Computer Science Search query Search ANU web, staff & maps Search COMP6700 Lectures Labs Assignments menu Search query Search ANU web, staff & maps Search Search COMP6700 labs Week 01: Welcome Week 02: Lab 1 Week 03: Lab 2 and HW 1 Week 04: Lab 3 and HW 2 Week 05: Drop-in Lab, HW 3 Week 06: Lab 4 and HW 4 Week 07: Mid-sem Exam Week 08: Free (Anzac Day) Week 09: Lab 5 and HW 5 Week 10: Lab 6 and HW 6 Week 11: Lab 7 and HW 7 Week 12: Lab 8 and HW 8 related sites Wattle Piazza Week 05: Homework 4 Learning Standard Class Design and Minimising Repetition The Problem Construct and test a Student class which stores the following data: Name Address Degree name Department Year Commenced Write accessor/mutator – get()/set(x) – methods for each field. If you are using an IDE, find out (ask your tutor for help, if necessary), how these methods can be generated automatically. Override toString() method of the Student class to return “Name, Department, Year Commenced” information on the Student object. Do you understand how does this affect the result of printing an object state? Write overloaded constructors so that a student can be constructed in several different way: Student() Student(name) Student(name, address) Student(name, address, department) Think how to minimise code repetition in these constructors by calling other constructor using the this(…) syntax. Programmers should always strive to avoid coding the same instruction more than once. This principle is known as DRY – “Don’t Repeat Yourself!” Write a test class, StudentTest, to test this class by creating an array of three students. Print out the students data as it’s done by toString() method (actually you don’t need to call this method; just put your object into a print statement and it gets called automatically!). Add a student ID field, studentID, and another static field nextID for counting students. Write a private method to increment the last value. Modify every constructor to set the value of studentID to the current value of nextID, and increment nextID each time a student object is constructed. Initialise the nextID to a static constant, STUDENT_ID_BASE=901000 (static variables are initialised prior to the first constructor call). Finally, modify toString() method to print the student information including the student id. Optional. Modify the above program to use an ArrayList instead of an array Student[]. Why the new version is better? Modify the Student class so that the student ID is assigned based on the year of commencement (to fit the ANU format where the first two digits are the last two digits of the commencement year, and the remaining five digits represent a unique number incremented by every new student enrolled on the same year; for example, the two IDs – 9207147 and 0207147 are both count 7,147th student enrolled correspondingly on 1992 and on 2002. You may assume that there was no enrolled students before the University was founded, in 1947). Assessment You will get up to two marks, if you present a solution to the Homework exercise during the next week lab, or submitted it by push you GitLab repository as explained in the Forking your GitLab repository exercise (part of the Lab 3). Updated:  13 Mar 2017/ Responsible Officer:  Head of School/ Page Contact:  Alexei Khorev Contact ANU Copyright Disclaimer Privacy Freedom of Information +61 2 6125 5111 The Australian National University, Canberra CRICOS Provider : 00120C ABN : 52 234 063 906 You appear to be using Internet Explorer 7, or have compatibility view turned on. Your browser is not supported by ANU web styles. » Learn how to fix this » Ignore this warning in future