EssayGhost Assignment代写,Essay代写,网课代修,Quiz代考

EssayGhost-Essay代写,作业代写,网课代修代上,cs代写代考

一站式网课代修,论文代写

高质量的Assignment代写、Paper代写、Report代写服务

EG1hao
网课代修代上,cs代写代考
C/C++代写
您的位置: 主页 > 编程案例 > C/C++代写 >
代写C++/C:LAB 4 - Java Write two Java classes: Matrix - C++代写
发布时间:2021-07-25 16:03:50浏览次数:
Assessment: 5% of the total course mark.Submission Deadline: You will receive a mark only for the codes that are demonstrated in front of a TA by the end of the lab. Additionally, you have to submit on Avenue a text le (with extension txt) containing each java class that you write (just change the extension java to txt). The name of the le should indicate the name of the class and your student ID number. The online submission has to be done by the end of the lab session.Description: Write two Java classes: Matrix, which represents matrices with integer ele-ments, and UpperTriangularMatrix to represent upper triangular matrices with integer elements stored e ciently. The accompanying le Matrix.java contains an incomplete declaration of the Matrix class. You need to complete the declarations of incomplete methods or constructors according to the speci cations given below. Additionally, you need to write the declaration of the class UpperTriangularMatrix. A class to test class Matrix and class UpperTriangularMatrix are provided as samples. However, you may need to perform additional testing to ensure that your code meets all the speci cations. A demo class will be provided for the demonstration in the lab.Specifications:Class Matrix has only the following instance elds, which have to be private: an integer to store the number of rows an integer to store the number of columns. a two dimensional array of integers to store the matrix elements. Class Matrix contains at least the following constructors: public Matrix(int row, int col) constructs a row-by-col matrix withall elements equal to 0; if row 0, the number of rows of the matrix is set to 3; likewise, if col 0 the number of columns of the matrix is set to 3. public Matrix(int[][] table) constructs a matrix out of the two dimen-sional array table, with the same number of rows, columns, and the same element in each position as array table.Class Matrix contains at least the following methods:1)public int getElement(int i, int j) throws IndexOutOfBoundsException returns the element on row i and column j of this matrix; it throws an ex-ception if any of indexes i and j is not in the required range (rows and columns indexing starts with 0); the detail message of the exception should read: In-valid indexes .2)public boolean setElement(int x, int i, int j) if i and j are valid indexes of this matrix, then the element on row i and column j of this matrix is assigned the value x and true is returned; otherwise false is returned and no change in the matrix is performed. 3)public Matrix copy() returns a deep copy of this Matrix. Note: A deep copy does not share any piece of memory with the original. Thus, any change performed on the copy will not a ect the original.4) public void addTo(Matrix m) throws ArithmeticException adds Matrixm to this Matrix (note: this Matrix WILL BE CHANGED) ; it throws an exception if the matrix addition is not de ned (i.e, if the matrices do not have the same dimensions); the detail message of the exception should read: Invalid operation .5)public Matrix subMatrix(int i, int j) throws ArithmeticException returns a new Matrix object, which represents a submatrix of this Matrix, formed out of rows 0 through i and columns 0 through j. The method should rst check if values i and j are within the required range, and throw an exception if any of them is not. The exception detail message should read: Submatrix not de ned . Note: The new object should be constructed in such a way that changes in the new matrix do not a ect this Matrix.6)public boolean isUpperTr() returns true if this Matrix is upper trian-gular, and false otherwise. A matrix is said to be upper triangular if all elements below the main diagonal are 0. Note that the main diagonal contains the elements situated at positions where the row index equals the column in-dex. In the following examples the main diagonal contains elements 1,9,3.Example of a 3-by-3 upper triangular matrix: 1 4 1 0 9 0 0 0 3Example of a 3-by-4 upper triangular matrix:

所有的编程代写范围:essayghost为美国、加拿大、英国、澳洲的留学生提供C语言代写、代写C语言、C语言代做、代做C语言、数据库代写、代写数据库、数据库代做、代做数据库、Web作业代写、代写Web作业、Web作业代做、代做Web作业、Java代写、代写Java、Java代做、代做Java、Python代写、代写Python、Python代做、代做Python、C/C++代写、代写C/C++、C/C++代做、代做C/C++、数据结构代写、代写数据结构、数据结构代做、代做数据结构等留学生编程作业代写服务。