Hallo Java-Forum!
Ich sitze grade an einer Programmieraufgabe zum Thema Vererbung,Arrays und jUnit Tests.
An diesem jUnit Test hänge ich aber grade etwas fest(die Vorlesung dazu fiel aufgrund der Corona-Situation aus)
Ich versuche den tatsächlichen Wert in die AssertEquals Methode einzubauen aber der compiler erkennt den Typ nicht.
Im Anhang befindet sich die Aufgabenstellung und nachfolgend die Klassen.
Hoffe mir kann hier jemand weiterhelfen
Ich sitze grade an einer Programmieraufgabe zum Thema Vererbung,Arrays und jUnit Tests.
An diesem jUnit Test hänge ich aber grade etwas fest(die Vorlesung dazu fiel aufgrund der Corona-Situation aus)
Ich versuche den tatsächlichen Wert in die AssertEquals Methode einzubauen aber der compiler erkennt den Typ nicht.
Im Anhang befindet sich die Aufgabenstellung und nachfolgend die Klassen.
Hoffe mir kann hier jemand weiterhelfen
Java:
package edu.hm.cs.swe2.shoppingmall;
public class ShoppingMall {
public Shop[] shops;
public ShoppingMall(int shopCount) {
if (shopCount < 1 || shopCount > 500) {
shopCount = 10;
} else {
this.shops = new Shop[shopCount];
}
}
public int addShops(Shop... shopsToAdd) {
int currentnumber = 0;
int notPlacable = 0;
for (Shop shop : shopsToAdd) {
if (this.shops.length <= currentnumber + 1 && this.shops[currentnumber] != null) {
this.shops[currentnumber] = shop;
} else {
notPlacable++;
}
currentnumber++;
}
return notPlacable;
}
public float calculateRent() {
float totalRent = 0;
return totalRent;
}
}
Java:
package edu.hm.cs.swe2.shoppingmall;
import java.time.LocalDateTime;
public class Shop {
private int area;
private String name;
private int rent;
private LocalDateTime openingTime;
private LocalDateTime closingTime;
private Shop(int area, String name, int rent) {
}
public String toString() {
return String.format("name: %s area: %s rent: %s", name, area, rent);
}
public int getArea() {
return this.area;
}
public void setArea(int area) {
this.area = area;
}
public int getRent() {
return this.rent;
}
public void setRrea(int area) {
this.area = area;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
}
Java:
package edu.hm.cs.swe2.shoppingmall;
public class SecurityCountable {
int personCount;
void addPerson() {
personCount = personCount + 1;
}
void removePerson() {
personCount = personCount - 1;
}
int showPersonCount() {
return personCount;
}
// Methode die einen Alarm ausgibt
}
Java:
package edu.hm.cs.swe2.shoppingmall;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
class ShoppingMallTest {
@Test
void TestShoppingMall() {
int shopCountTest = 0;
ShoppingMall TestShoppingMall = new ShoppingMall(shopCountTest);
int expectedResult = 10;
int actualResult = 0;
assertEquals(expectedResult, ShoppingMall(0));
}
}