Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HI I need help with understanding what this means and how to write this in another class (class Lab1b). Im really stuck on how to

HI I need help with understanding what this means and how to write this in another class (class Lab1b). Im really stuck on how to write out vdef from Class Vector or if i misunderstand.

[You implement the classLab1b, which contains only the method main (..). Use System.out.println(..)to write a vector or the return value of a method to the console. Implement the following lines that test all methods of Vector.]

[Write out the content of vdef before you create the first instance of Vector. Create the vectorv1 using the default constructor and write out its content. Change the coordinates of the default vector vdef to (1.0, 2.0, 3.0), use the methodsetToDefault()ofv1, and write out the content of v1.]

This is what I got in Class Vector. Here we got vdef. Should I retrieve it to Class Lab1b and then print it out somehow and display it and change its values..?

image text in transcribed

public void set Tobefault() {// setTobefault() sets the values of x,y,z x=vdcfx; y=vdcfy; \} z - vicf.z; public Vector plus(Vector v1, Vector v2) \{ \} return new Vector(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); public Vector minus(Vector v) \{ \} return new Vectar(xv.x,yv.y,zv.z); public vector mult(double m) \{ return new Vectar(x+m,y+m,z+m); \} public double mult(Vector v) \{ \} return x+vx+y+vy+z+ v.r; public double length() \{ \} return Nath.sart (x+x+y+y+z+z); public Vector nom() f double len - length(); \} return new Vector( x/ len, y/ len, z/ len); public Vector matrixult(double[][] m) \{ if (m.length 13m[].length 3 ) \{ return this; \} double now x+m[][6]+y+m[1][6]+z+m[2][]; double nowY x+m[][1]+ym[1][1]+zm[2][1] double nowz x+m[][2]+y+m[1][2]+zm[2][2]; return new Vector(new , nowY, nowz); \} public int compareTo(Vector v) \{ double diff - length() - v.length(); if (diff ) ) \{ return 1; f else \{ return e; \} \} public string tostring() \{ return string-farmat(" (%.2f,x.2f,x.2f)n,x,y,z); \} public static void main(String[] args) \{ Vector v1 - new Vector(1,2,3); Vector v2 - new Vector (4,5,6); Vector v3 - v1.plus (v1,v2); \} Systom.ourt.print ln(v3); \}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

Students also viewed these Databases questions

Question

Th e last time I complained, nothing happened.

Answered: 1 week ago

Question

Th ey could have made my situation worse.

Answered: 1 week ago