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

View File

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

View File

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

16
more_on_classes/pom.xml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.oop</groupId>
<artifactId>more_on_classes</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
</project>

View File

@ -0,0 +1,7 @@
package com.oop;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

Binary file not shown.