HTML und CSS Frage?

Hallo,

ich möchte die Grüne und gelbe Kärtchen im zweiten <section> nach oben in die MITTE schieben. Jedoch hakt es bisschen bei mir. Zudem müssen wir nur Flexbox benutzen das heisst kein margin oder position etc....

HTML_CODE:

<!DOCTYPE html>

<html lang="en">

<head>

  <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Flexbox</title>

  <link rel="stylesheet" href="../CSS/style.css">

</head>

<body>

  <header>

    <div class="layout2">

 <nav>

    <div class="container">

      <ul>

        <li>

          <a class="item1" href="#">LOGO</a>

          <a class="item" href="#">Menu 1</a>

          <a class="item" href="#">Menu 2</a>

          <a class="item" href="#">Menu 3</a>

          <a class="item2" href="#">Button</a>

        </li>

      </ul>

    </div>

  </nav>

 

</div>

</header>

<main>

  <div class="layout4">

  <section>

   

 

    <div class="laayout2">

     

      <div class="brownhelp"><div class="brownbox"></div></div>

      <div class="sectionone">

        <div class="content1">

          <div class="border"></div>

    <div class="border1"></div>

    <div class="border2"></div>

    <div class="border3"></div>

    <div class="border4"></div>

        </div>

  </div>

</div>

</section>

<section>

    <div class="laayout3">

  <div class="sectiontwo">

      <div class="content2">

        <div class="box"></div>

        <div class="box2"></div>

        <div class="box3"></div>

        <div class="box4"></div>

       

      </div>

    </div>

    </div>

</section>

</div>

</main>

</body>

</html>

CSS_CODE:

*{

  margin: 0;

  box-sizing: border-box;

}

header {

  background-color: #cae1fc;;

}

.layout2 {

  display: flex;

  align-items: center;

  justify-content: space-around;

  flex-direction: column;

}

.container {

  height: 150px;

  width: 1425px;

  background-color:rgb(80, 98, 104);

  display: flex;

  justify-content: space-around;

  align-items: center;

}

div ul {

  width: 100%;

}

div li {

  display: flex;

   justify-content: space-around;

   align-items:center;

  list-style: none;

}

.item {

  background-color: rgb(39, 185, 171);

  width: 120px;

  height: 50px;

  color: #fff;

  font-weight: bold;

  font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;

  font-size: large;

  display: flex;

  justify-content: center;

  flex-direction: column;

  text-align: center;

  text-decoration: none;

 

}

.item1 {

  background-color: rgb(193, 67, 67);

  width: 115px;

  height: 50px;

  color: #fff;

  font-weight: bold;

  font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;

  font-size: large;

  display: flex;

  justify-content: center;

  flex-direction: column;

  text-align: center;

  text-decoration: none;

}

.item2 {

  background-color: rgb(112, 29, 189);

  width: 80px;

  height: 90px;

  color: #fff;

  font-weight: bold;

  font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;

  font-size: small;

  display: flex;

  text-align: center;

  justify-content: center;

  flex-direction: column;

  text-decoration: none;

}

.layout2 > nav {

  height: 100vh;

}

nav {

  display: flex;

  align-items: flex-end;

  max-height: 170px;

}

/**/

.layout4 {

  background-color: #cae1fc;

}

.laayout2 {

  height: 1000px;

  display: flex;

  justify-content:space-around;

}

.sectionone {

  display: flex;

  justify-content: center;

  align-items: flex-end;

  max-height: 345px;

  width: 270px;

 

}

.content1 {

  display: flex;

  flex-direction: column;

  align-items: flex-end;

  gap: 20px;

  background-color: #cae1fc;;

}

.border {

  background-color: #fff;

  width: 225px;

  height: 45px;

 

}

.border1 {

  background-color: #fff;

  width: 225px;

  height: 45px;

}

.border2 {

  background-color: #fff;

  width: 225px;

  height: 45px;

 

}

.border3 {

  background-color: #fff;

  width: 225px;

  height: 45px;

 

}

.border4 {

  background-color: #fff;

  width: 225px;

  height: 45px;

}

.brownhelp {

  display: flex;

  align-items: flex-end;

  justify-content: center;

  max-height: 345px;

  width: 1200px;

}

.brownbox {

  background-color: burlywood;

  width: 1150px;

  height: 305px;

 

}

/*YELLOW*/

.laayout3 {

  display: flex;

  justify-content: space-around;

  align-items: flex-start;

  height: auto;

 

}

.sectiontwo {

  display: flex;

  width: 800px;

  justify-content: space-around;

  align-items: center;

}

.content2 {

  display: flex;

  justify-content: space-around;

  gap: 200px;

}

.box {

  background-color: yellow;

  width: 200px;

  height: 190px;

}

.box2 {

  background-color: green;

  width: 200px;

  height: 190px;

}

.box3 {

  background-color: yellow;

  width: 200px;

  height: 190px;

}

.box4 {

  background-color: green;

  width: 200px;

  height: 190px;

}

Bild zum Beitrag
HTML, Webseite, CSS, JavaScript, HTML5, Code, PHP, Programmiersprache, Webdesign, Webentwicklung, Frontend, Visual Studio Code
Java Input/Output Tests Junit?

Hallo, 

Ich habe folgendes Problem: Ich habe eine Klasse, die die Benutzerinteraktion (Input/Output) handhabt und ich muss Junit4 Tests dafür schreiben. 

Die Klasse, die ich testen möchte, sieht in etwa so aus:

package program;
// imports
public class UserInteraction {
    private Program program;


    private UserInteraction(){
        program = new Program();
    }


    // Menu display
    private void start() {
        while (!program.getProgramStarted) {
            String input = readInput();
            switch (input) {
            case "1":
                addUser();
                break;
            case "2":
                deleteUser();
                break;
            case "3":
                // ...
            default:
                System.err.println("Unknown option");
                break;
            }
        }
    }


    private void addUser() {
        // Output
        String username = readInput();
        program.addUser(username);
        System.out.println("User " + username + "added");
    }


    private void deleteUser() {
        // Output
        String username = readInput();
        program.deleteUser(username);
        System.out.println("User " + username + "deleted");
    }


    @SuppressWarnings("resource")
    private String readInput() {
        return (new Scanner(System.in)).nextLine();
    }


    public void main(String[] args) {
        UserInteraction ui = new UserInteraction();
        ui.start();
    }


}

Die Program Klasse so:

package program;
// imports
public class Program {
    // fields
    private User currentUser;
    private List<User> user = new ArrayList<User>();
    // constructor


    public void addUser(String name) throws Exception {
        if (user.size() >= 6) {
            throw new Exception();
        }
        int newID = user.size() + 1;
        user.add(new User(name, newID));
    }


    public String[] getALlUser() {
        int counter = 0;
        String[] userArray = new String[user.size()];


        for (User s : user) {
            userArray[counter++] = s.toString();
        }
        return userArray;
    }
}

Nun möchte ich zum Beispiel testen, ob die folgende Eingabe korrekt verarbeitet wird:

1
John
=> Benutzer John hinzugefügt

Zu diesem Zweck habe ich einen Junit-Test geschrieben, der wie folgt aussieht:

package tests;


import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintStream;


import org.junit.After;
import org.junit.Test;


import program.*;


public class UserInteractionTest {


    private final InputStream originalIn = System.in;
    private final PrintStream originalOut = System.out;
    private Program program;


    @After
    public void restoreStreams() {
        System.setIn(originalIn);
        System.setOut(originalOut);
    }


    @Test
    public void testCreateUser() throws Exception {
        String input = "1\nJohn\n";
        ByteArrayInputStream in = new ByteArrayInputStream(input.getBytes());
        System.setIn(in);
        ByteArrayOutputStream outContent = new ByteArrayOutputStream();
        System.setOut(new PrintStream(outContent)); // Leitet System.out um


        program = new Program();
        try {
            program.main(null);
        } finally {
            System.setIn(originalIn);
        }
        String expectedOutput = "User John added";
        assertTrue("Output not found", outContent.toString().contains(expectedOutput));
    }


}

Die Eingabe ("1\n") wird gemacht, aber danach wird keine Eingabe eingefügt, so dass der Test hängen bleibt.

Weiß jemand, wie man dieses Problem lösen kann? Oder gibt es vielleicht eine bessere Möglichkeit, die Eingabe/Ausgabe meines Java-Programms zu testen/zu überprüfen?

Vielen Dank im Voraus!

Java, Code, Eclipse, Programmiersprache
Wechselgeld Rechner in C?

Ich habe den folgenden Code:

#include <stdio.h>

int main(void)
{
    /* declarate variables */
    float price, paid, change;
    int cents;
    int rest;
    int cent1;
    int cent2;
    int cent5;
    int cent10;
    int cent20;
    int cent50;
    int eur1;
    int eur2;

    /* print out price and paid amount */
    printf("Rechnungsbetrag: ");
    scanf("%f", &price);

    printf("Erhaltener Betrag: ");
    scanf("%f", &paid);

    /* calculate the change as float */
    change = paid - price;

    printf("======================\n");
    printf("Rückgeld: %.2f EUR\n", change);
    printf("======================\n");

    /* calculate the change in cents */
    cents = change * 100;


    eur2   = cents / 200;
    rest = cents % 200;

    eur1   = rest / 100;
    rest = cents % 100;

    cent50 = rest / 50;
    rest = cents % 50;

    cent20 = rest / 20;
    rest = cents % 20;

    cent10 = rest / 10;
    rest = cents % 10;

    cent5  = rest / 5;
    rest = cents % 5;

    cent2  = rest / 2;
    rest = cents % 2;

    cent1  = rest / 1;


    printf("1 Cent:  %d\n", cent1);
    printf("2 Cent:  %d\n", cent2);
    printf("5 Cent:  %d\n", cent5);
    printf("10 Cent: %d\n", cent10);
    printf("20 Cent: %d\n", cent20);
    printf("50 Cent: %d\n", cent50);
    printf("1 EUR:   %d\n", eur1);
    printf("2 EUR:   %d\n", eur2);


    return 0;
}

Es werden zwei Werte Eingeben, einmal den Rechnungspreis und den erhaltenen Betrag, dann wird das Wechselgeld ausgerechnet. Danach soll die Anzahl der jeweiligen Münzen errechnet werden, die es benötigt um den Betrag des Wechselgeldes zu erreichen.

Wenn ich, zum Beispiel, als Rechnungsbetrag 1.50 habe, und als Erhaltenen Betrag 2.00, dann gibt es mir 1 50 Cent münze und eine 10 cent münze aus.

Ich habe verschiedene Beträge ausprobiert und es kommt immer diese extra 10 Cent Münze raus.

Wie kann ich das beheben?

Computer, Linux, Code, Programmiersprache, Algorithmus, C (Programmiersprache)

Meistgelesene Beiträge zum Thema Code