MoreOnClasses

This commit is contained in:
2024-09-16 08:47:06 +02:00
parent 2c715a1d0e
commit f7483e5e68
10 changed files with 33 additions and 9 deletions

View File

@ -1,5 +1,6 @@
package com.example;
import com.practice.Vehicle; //Import a java file from another java package
import java.util.Scanner;
public class Main {
@ -84,6 +85,5 @@ public class Main {
double p = Math.pow(2, 3);
System.out.println(p);
}
}

View File

@ -1,4 +1,4 @@
package com.example;
package com.practice;
public class Animal {
void bark(){

View File

@ -1,18 +1,19 @@
package com.example;
package com.practice;
public class Vehicle {
int maxSpeed;
int wheels;
String color;
double fuelCapacity;
Vehicle() {
static int counter;
public int maxSpeed;
public int wheels;
public String color;
public double fuelCapacity;
public Vehicle() {
this.setColor("Red");
}
Vehicle(String c) {
this.setColor(c);
}
void horn() {
public void horn() {
System.out.println("Beep!");
}