Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // SchaltgTest.java
- // Klasse zum Testen der Zweitor-Klassen
- // Praktikum Programmieren
- // ... Package- u. Import-Deklarationen
- package prakt.v6;
- import java.io.*;
- import java.util.Locale;
- import java.util.Scanner;
- public class SchaltgTest
- {
- private static Scanner makeScanner(String path)
- {
- Scanner input = null;
- if (path == null)
- input = new Scanner(System.in);
- else
- { try
- { input = new Scanner(new File(path));
- }
- catch (FileNotFoundException ex)
- {
- System.out.println(ex.getMessage());
- System.out.println("Weiterarbeit mit Standard-Eingabe");
- input = new Scanner(System.in);
- }
- }
- return input;
- }
- public static void main(String[] args) {
- Locale.setDefault(Locale.US);
- String dpfad = null;
- if (args.length > 0){
- dpfad = args[0];
- }
- Scanner input = SchaltgTest.makeScanner(dpfad);
- SchaltgBuilder Schaltung = new SchaltgBuilder(input);
- boolean run = true;
- while (run){
- if (dpfad == null)
- System.out.println("Schaltung eingeben: ");
- Zweipol Schltg = Schaltung.read();
- if (Schltg == null) {
- run = false;
- }
- if (run){
- if(dpfad == null)
- System.out.println("Frequenz eingeben: ");
- double Freq = input.nextDouble();
- System.out.println("Komplexer Widerstand der Schaltung: "+ Schltg.widerstand(Freq));
- System.out.println("Komplexer Widerstand in Polardarstellung: "+ Schltg.widerstand(Freq).toPolarStr());
- System.out.println();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement