• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 3 fuera de 27 páginas
Examen

Code HS Unit 4 Study Guide Questions Graded A+ 2025/2026

Document preview thumbnail
Vista previa 3 fuera de 27 páginas

Code HS Unit 4 Study Guide Questions Graded A+ 2025/2026 4.1.7 Calling A Method - RectangleT: public class RectangleTester extends ConsoleProgram { public void run() { /* * Rectangle is the name of the class. Every Rectangle * has a width and a height. But the specific instances * have their own dimensions. */ Rectangle r1 = new Rectangle(7, 14); Sln(Height()); Sln(Width()); Sln(Area()); } } R: public class Rectangle { private int width; private int height; public Rectangle(int rectWidth, int rectHeight) { width = rectWidth; height = rectHeight; } public int getArea()

Vista previa del contenido

Code HS Unit 4 Study Guide Questions Graded A+
2025/2026
4.1.7 Calling A Method - RectangleTester.java:
public class RectangleTester extends ConsoleProgram
{
public void run()
{
/*
* Rectangle is the name of the class. Every Rectangle
* has a width and a height. But the specific instances
* have their own dimensions.
*/
Rectangle r1 = new Rectangle(7, 14);
System.out.println(r1.getHeight());
System.out.println(r1.getWidth());
System.out.println(r1.getArea());
}
}

Rectangle.java:
public class Rectangle
{
private int width;
private int height;

public Rectangle(int rectWidth, int rectHeight)
{
width = rectWidth;
height = rectHeight;
}

public int getArea()
{
return width * height;
}

public int getHeight()
{
return height;
}

public int getWidth()
{
return width;

,}

public String toString()
{
return "Rectangle with width: " + width + " and height: " + height;
}
}

4.1.8 Using the Point Class - PointTester.java:
public class PointTester extends ConsoleProgram
{
public void run()
{
Point p = new Point(10, 5);
System.out.println(p);
p.move(3, 4);

System.out.println(p);

// Make a new point here at position (2, 4)
Point a = new Point(2, 4);

// Then print it out
System.out.println(a);
}
}

Point.java:
public class Point
{
private int x;
private int y;

public Point(int xCoord, int yCoord)
{
x = xCoord;
y = yCoord;
}

public void move(int dx, int dy)
{
x += dx;
y += dy;
}

public String toString()

, {
return x + ", " + y;
}
}

4.1.9 Using the Student Class - StudentTester.java:
public class StudentTester extends ConsoleProgram
{
public void run()
{
Student alan = new Student("Alan", "Turing", 11);
Student ada = new Student("Ada", "Lovelace", 12);
Student luke = new Student("Luke", "Drelick", 12);
// Add an entry for yourself here!

System.out.println(alan);
System.out.println(ada);
// Print out your student object
System.out.println(luke);
}
}

Student.java:
public class Student
{
private String firstName;
private String lastName;
private int gradeLevel;

public Student(String fName, String lName, int grade)
{
firstName = fName;
lastName = lName;
gradeLevel = grade;
}

public String toString()
{
return firstName + " " + lastName + " is in grade: " + gradeLevel;
}
}

4.2.5 Text Messages - Messages.java:
public class Messages extends ConsoleProgram
{
public void run()

Información del documento

Subido en
30 de enero de 2025
Número de páginas
27
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$10.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
PLANTER
3.5
(43)
Vendido
299
Seguidores
11
Artículos
37014
Última venta
1 semana hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes