Advertisement
Guest User

phonebook

a guest
Dec 14th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. main
  2. =======================================
  3. package Tester;
  4.  
  5. import java.io.FileNotFoundException;
  6.  
  7. import Cls.Phone;
  8.  
  9. public class MainPhone {
  10.  
  11.     public static void main(String[] args) throws FileNotFoundException {
  12.         ///final String FILE1 = "c:\\yana\\phone.txt";
  13.         new Phone("0525774072", "yana").save();
  14.        
  15.         System.out.println("Done");
  16.  
  17.     }
  18.  
  19. }
  20.  
  21. cls
  22. ======================================
  23. package Cls;
  24.  
  25. import java.io.File;
  26. import java.io.FileNotFoundException;
  27. import java.io.PrintWriter;
  28.  
  29. public class Phone{
  30.  
  31.     private String cellNum;
  32.     private String name;
  33.     private final int SUMCHARGE = -1;
  34.     private int lastPay=SUMCHARGE;
  35.     private final File PHONE_BOOK=new File("c:\\yana\\phone.txt");
  36.  
  37.     public Phone(String cellNum, String name) {
  38.         this.cellNum = cellNum;
  39.         this.name = name;
  40.     }
  41.  
  42.    
  43.  
  44.     public void save() throws FileNotFoundException {
  45.         PrintWriter pw = new PrintWriter(PHONE_BOOK);
  46.         pw.print("line number: " + cellNum + " owner: " + name + " last pay: "
  47.                 + lastPay);
  48.         pw.close();
  49.     }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement