SlideShare a Scribd company logo
Please help me with a UML class diagram for the following code:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class FileEdit {
public static List lines = new ArrayList();
public static void main(String[] args) throws IOException
{
Scanner s = new Scanner(System.in);
System.out.print("EDIT: ");
String fileName = s.nextLine();
BufferedReader br = new BufferedReader(new FileReader(new File(fileName)));
String str="";
int count=0;
while((str=br.readLine())!=null)
{
lines.add(count, str);
System.out.println((++count) + "> "+ str);
}
String text="";
String command = "";
System.out.print((++count)+"> ");
command=s.nextLine();
String commandArr[];
int flag;
while(!command.equals("E"))
{
flag=0;
commandArr = command.split("s");
if(commandArr[0].equals("I")) //Insertion
{
while(true)
{
if(commandArr.length==1&&flag!=2)
{
System.out.print((count)+"> ");
text = s.nextLine();
insertLine(text,count-1);
}
else if(commandArr.length==2&&flag!=2)
{
System.out.print((commandArr[1])+"> ");
count=Integer.parseInt(commandArr[1]);
text = s.nextLine();
insertLine(text,Integer.parseInt(commandArr[1])-1);
}
else
insertLine(text,count-1);
System.out.print((++count)+"> ");
command=s.nextLine();
commandArr = command.split("s");
if(commandArr[0].equals("I")||commandArr[0].equals("L")||commandArr[0].equals("D")||comm
andArr[0].equals("E"))
{
flag=1;
break;
}
else
{
flag=2;
text=command;
}
}
}
else if(commandArr[0].equals("L")) //Listing
{
printList();
}
else if(commandArr[0].equals("D")) //Deletion
{
if(commandArr.length==1)
{
deleteLine(count-1,count-1);
}
else if(commandArr.length==2)
{
deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[1])-1);
}
else if(commandArr.length==3)
{
deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[2])-1);
}
count=lines.size();
}
if(flag!=1)
{
System.out.print((count++)+"> ");
command = s.nextLine();
}
}
}
public static void insertLine(String text,int count)
{
if (count >= lines.size()) {
for(int i = lines.size(); i <= count; i++) {
lines.add(null);
}
}
lines.set(count,text);
}
public static void deleteLine(int start,int end)
{
for(int i=start;i<=end;i++)
lines.remove(i);
}
public static void printList()
{
for(int i=0;i "+lines.get(i));
}
}

More Related Content

PDF
Please help solve! Suppose that X is an exponential random variable .pdf
PDF
Please help me i will give good rating a) A wheel has 37 numbers 0.pdf
PDF
Please help me answer this question.Explain how oxygen content acc.pdf
PDF
PLEASE HELP IN C++For this test, you will need to create the follo.pdf
PDF
please help and thank you ! Experiments by Murphy et al. (2014) on t.pdf
PDF
PLEASE HELP (also please dont answer with path because there is no .pdf
PDF
please explain these topics if possible How companies account for.pdf
PDF
Pls introduced to various themes and theoretical issues pertaining t.pdf
Please help solve! Suppose that X is an exponential random variable .pdf
Please help me i will give good rating a) A wheel has 37 numbers 0.pdf
Please help me answer this question.Explain how oxygen content acc.pdf
PLEASE HELP IN C++For this test, you will need to create the follo.pdf
please help and thank you ! Experiments by Murphy et al. (2014) on t.pdf
PLEASE HELP (also please dont answer with path because there is no .pdf
please explain these topics if possible How companies account for.pdf
Pls introduced to various themes and theoretical issues pertaining t.pdf

More from aioils (20)

PDF
please! 1. Match and pair the following basic genetic conce.pdf
PDF
Please write out steps )You have genotyped an entire population o.pdf
PDF
Please write out the steps )_You have genotyped an entire populat.pdf
PDF
Please Use The Code Provided below. Thanks Study the Python code .pdf
PDF
Please Use the Code Provided below. Thanks Visit LL Queue ; add.pdf
PDF
Please this is very important Im on a deadline The joint probabilit.pdf
PDF
Please solve. In the Assembly Department of Martinez Company, budget.pdf
PDF
Please do parts labeled TODO LinkedList.java Replace.pdf
PDF
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
PDF
Please do number 1 as its my choice for this project but, if there.pdf
PDF
Please show workstepsYou have genotyped an entire population of l.pdf
PDF
Please show all steps of algebra. I have the answer shown below but .pdf
PDF
Please solve the following and provide explanation (assembly languag.pdf
PDF
Please show all steps, thank you! 2. Suppose X and Y hav.pdf
PDF
Please show all steps and dont copy other answers. 4. Suppose {Y1,Y.pdf
PDF
Please read the case and do the external factors based on the factor.pdf
PDF
Please provide everything correct. I will upvote!! Why do proposals .pdf
PDF
Please please please write this in visual studios. Ive been getting.pdf
PDF
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
PDF
please interview a friendfamily membercolleague.your responses sho.pdf
please! 1. Match and pair the following basic genetic conce.pdf
Please write out steps )You have genotyped an entire population o.pdf
Please write out the steps )_You have genotyped an entire populat.pdf
Please Use The Code Provided below. Thanks Study the Python code .pdf
Please Use the Code Provided below. Thanks Visit LL Queue ; add.pdf
Please this is very important Im on a deadline The joint probabilit.pdf
Please solve. In the Assembly Department of Martinez Company, budget.pdf
Please do parts labeled TODO LinkedList.java Replace.pdf
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
Please do number 1 as its my choice for this project but, if there.pdf
Please show workstepsYou have genotyped an entire population of l.pdf
Please show all steps of algebra. I have the answer shown below but .pdf
Please solve the following and provide explanation (assembly languag.pdf
Please show all steps, thank you! 2. Suppose X and Y hav.pdf
Please show all steps and dont copy other answers. 4. Suppose {Y1,Y.pdf
Please read the case and do the external factors based on the factor.pdf
Please provide everything correct. I will upvote!! Why do proposals .pdf
Please please please write this in visual studios. Ive been getting.pdf
please navigate to cs112 webpage and go to assignments -- Trees. Th.pdf
please interview a friendfamily membercolleague.your responses sho.pdf
Ad

Recently uploaded (20)

PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Institutional Correction lecture only . . .
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Basic Mud Logging Guide for educational purpose
PDF
Computing-Curriculum for Schools in Ghana
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Cell Types and Its function , kingdom of life
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Lesson notes of climatology university.
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Final Presentation General Medicine 03-08-2024.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
VCE English Exam - Section C Student Revision Booklet
Institutional Correction lecture only . . .
O7-L3 Supply Chain Operations - ICLT Program
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
GDM (1) (1).pptx small presentation for students
Basic Mud Logging Guide for educational purpose
Computing-Curriculum for Schools in Ghana
Complications of Minimal Access Surgery at WLH
Cell Types and Its function , kingdom of life
human mycosis Human fungal infections are called human mycosis..pptx
Microbial diseases, their pathogenesis and prophylaxis
Anesthesia in Laparoscopic Surgery in India
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Lesson notes of climatology university.
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Final Presentation General Medicine 03-08-2024.pptx
Ad

Please help me with a UML class diagram for the following code im.pdf

  • 1. Please help me with a UML class diagram for the following code: import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class FileEdit { public static List lines = new ArrayList(); public static void main(String[] args) throws IOException { Scanner s = new Scanner(System.in); System.out.print("EDIT: "); String fileName = s.nextLine(); BufferedReader br = new BufferedReader(new FileReader(new File(fileName))); String str=""; int count=0; while((str=br.readLine())!=null) { lines.add(count, str); System.out.println((++count) + "> "+ str); } String text=""; String command = ""; System.out.print((++count)+"> "); command=s.nextLine(); String commandArr[]; int flag; while(!command.equals("E")) { flag=0; commandArr = command.split("s"); if(commandArr[0].equals("I")) //Insertion {
  • 2. while(true) { if(commandArr.length==1&&flag!=2) { System.out.print((count)+"> "); text = s.nextLine(); insertLine(text,count-1); } else if(commandArr.length==2&&flag!=2) { System.out.print((commandArr[1])+"> "); count=Integer.parseInt(commandArr[1]); text = s.nextLine(); insertLine(text,Integer.parseInt(commandArr[1])-1); } else insertLine(text,count-1); System.out.print((++count)+"> "); command=s.nextLine(); commandArr = command.split("s"); if(commandArr[0].equals("I")||commandArr[0].equals("L")||commandArr[0].equals("D")||comm andArr[0].equals("E")) { flag=1; break; } else { flag=2; text=command; } } } else if(commandArr[0].equals("L")) //Listing { printList();
  • 3. } else if(commandArr[0].equals("D")) //Deletion { if(commandArr.length==1) { deleteLine(count-1,count-1); } else if(commandArr.length==2) { deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[1])-1); } else if(commandArr.length==3) { deleteLine(Integer.parseInt(commandArr[1])-1,Integer.parseInt(commandArr[2])-1); } count=lines.size(); } if(flag!=1) { System.out.print((count++)+"> "); command = s.nextLine(); } } } public static void insertLine(String text,int count) { if (count >= lines.size()) { for(int i = lines.size(); i <= count; i++) { lines.add(null); } } lines.set(count,text); } public static void deleteLine(int start,int end) { for(int i=start;i<=end;i++)
  • 4. lines.remove(i); } public static void printList() { for(int i=0;i "+lines.get(i)); } }