Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- CarClass [] array = new CarClass[10];
- String MARKA;
- String MODEL;
- System.out.println("1. ADD");
- System.out.println("2. REMOVE");
- System.out.println("3. PRINT");
- System.out.println("4. EXIT");
- boolean check = true;
- while(check) {
- System.out.println("Моля въведете опция от 1 до 4: ");
- int choice = input.nextInt();
- System.out.println();
- switch (choice) {
- case 1:
- System.out.print("Моля въведете МАРКА : ");
- MARKA = input.next();
- System.out.print("Моля въведете МОДЕЛ : ");
- MODEL = input.next();
- System.out.println();
- for (int i = 0; i < array.length; i++) {
- if(array[i] == null){
- array[i] = new CarClass(MARKA,MODEL);
- break;
- }
- }
- break;
- case 2:
- System.out.print("Моля въведете МАРКА : ");
- MARKA = input.next();
- System.out.print("Моля въведете МОДЕЛ : ");
- MODEL = input.next();
- System.out.println();
- for (int i = 0; i < array.length; i++) {
- if (array[i] != null) {
- if(array[i].getMarka().equals(MARKA) && array[i].getModel().equals(MODEL)){
- array[i] = null;
- break;
- }
- }
- }
- break;
- case 3:
- for (CarClass car: array) {
- if(car != null){
- System.out.println(car.getMarka() + " " + car.getModel());
- }
- }
- break;
- case 4:
- System.out.println("END");
- check = false;
- break;
- default:
- System.out.println("НЕВАЛИДНА КОМАНДА !");
- }
- }
- }// end of main()
- }// end of Class : CarMain
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement