-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask3_4.java
More file actions
81 lines (77 loc) · 2.25 KB
/
Copy pathtask3_4.java
File metadata and controls
81 lines (77 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import java.util.ArrayList;
import java.util.Scanner;
abstract class computer{
String CompanyName;
int Model;
String ProcessorType;
String color;
int price;
computer(String CompanyName,int Model,String ProcessorType,String color,int price){
this.CompanyName =CompanyName;
this.Model=Model;
this.ProcessorType=ProcessorType;
this.color=color;
this.price=price;
}
abstract void DisplayData();
}
class desktopComputer extends computer{
desktopComputer(){
super("Dell",2019,"core i5","black",500);
}
void DisplayData(){
System.out.println("CompanyName:"+CompanyName);
System.out.println("Model:"+2019);
System.out.println("Processor Type:"+ProcessorType);
System.out.println("Color:"+color);
System.out.println("Price:"+price);
}
}
class laptopComputer extends computer{
String camera;
String size;
double weight;
laptopComputer(){
super("Dell",2019,"core i5","black",500);
this.camera="Canon";
this.size="12*12";
this.weight=15.9;
}
void DisplayData(){
System.out.println("CompanyName:"+CompanyName);
System.out.println("Model:"+2019);
System.out.println("Processor Type:"+ProcessorType);
System.out.println("Color:"+color);
System.out.println("Price:"+price);
System.out.println("Camera:"+camera);
System.out.println("Size:"+size);
System.out.println("Weight:"+weight);
}
}
public class task3_4{
public static void main(String[] args){
ArrayList<String> myComputer = new ArrayList<String>();
System.out.println("Enter Type of computer like Dell or Hp");
Scanner input = new Scanner(System.in);
for(int i=1;i<=3;i++){
String name=input.nextLine();
myComputer.add(name);
}
for(int i=1;i<=3;i++){
System.out.println("Your "+i+" Computer ");
if(myComputer.contains("Dell")|| myComputer.contains("dell"))
{
desktopComputer Computer=new desktopComputer();
Computer.DisplayData();
myComputer.remove("cat");
}
else if(myComputer.contains("Hp") || myComputer.contains("hp"))
{
laptopComputer computer2=new laptopComputer();
computer2.DisplayData();
myComputer.remove("Hp");
}
else{System.out.println("Not Present in our list");}
}
}
}