Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- class Interval {
- private int linf,lsup,nrtestate,nrgasite;
- public Interval(int inferior,int superior)
- {
- linf=inferior;
- lsup=superior;
- }
- public void testare(Double x)
- {
- nrtestate++;
- boolean istrue = ((x >=linf) && (x <= lsup));
- if(istrue) nrgasite++;
- }
- public String toString()
- {
- return "[" + linf + "," + lsup + "]";
- }
- }
- class Main
- {
- public static void main(String arg[])
- {
- try
- {
- BufferedReader file = new BufferedReader
- (new InputStreamReader(new FileInputStream ("intervale.dat")));
- Integer nr_citit1,nr_citit2;
- String inf,sup;
- int nr=0;
- Interval[] obj = new Interval[100];
- while(( inf=file.readLine()) != null)
- {
- sup = file.readLine();
- obj[nr] = new Interval(Integer.parseInt(inf),Integer.parseInt(sup));
- System.out.print("\nIntervalul" + nr+ "=" + obj[nr]);
- nr++;
- }
- file.close();
- } catch(IOException e)
- {
- System.out.println("Error fisier!");
- System.exit(1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement