Product Attribute auf private gesetzt

Quellen hinzugefügt
main
Daniel Zikol 2025-12-11 01:18:32 +01:00
parent 8428ddffb2
commit 75b54e74f5
2 changed files with 30 additions and 9 deletions

View File

@ -0,0 +1,13 @@
Zum nachlesen.
Java OOP
Bro Code - Java Full course for free 2025
https://www.youtube.com/watch?v=xTtL8E4LzTQ
W3-Schools - Java Encapsulation
Get and Set
https://www.w3schools.com/java/java_encapsulation.asp
Code Gym - Get and Set
https://codegym.cc/de/groups/posts/getter-und-setter-in-java

View File

@ -1,13 +1,18 @@
package shoppackage; package shoppackage;
//Überlegen ob etwas private sein soll oder nicht /*
//Setter und getter erlernen falls private <---- Nacht darüber schlafen. TODO
Setter getter tutorial schauen
*/
public class Product { public class Product {
int prodID; private int prodID;
String name; private String name;
double transportWeight; private double transportWeight;
double netto; private double netto;
double mwst; private double mwst; // <----- Maybe final setzen
int lagerbestand; private int lagerbestand;
public Product(int prodID, String name, double transportWeight, double netto, double mwst, int lagerbestand) { public Product(int prodID, String name, double transportWeight, double netto, double mwst, int lagerbestand) {
this.prodID = prodID; this.prodID = prodID;
@ -28,7 +33,7 @@ public class Product {
return true; return true;
} }
// //Get ---> Methoden zum abrufen der Vals
public String getName() { public String getName() {
return name; return name;
} }
@ -49,4 +54,7 @@ public class Product {
public double getTransportWeight(){ public double getTransportWeight(){
return transportWeight; return transportWeight;
} }
} }