0% found this document useful (0 votes)
71 views7 pages

SmartDevice Class Overview

The document defines a SmartDevice class with attributes like device type, name, model number, IP address, battery percentage, WiFi status, and device status. It includes methods for device configuration, power management, and displaying device details, along with a static count of created devices. The Main1 class demonstrates creating SmartDevice objects, modifying their configurations, and displaying their details and total count.

Uploaded by

f24610012
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views7 pages

SmartDevice Class Overview

The document defines a SmartDevice class with attributes like device type, name, model number, IP address, battery percentage, WiFi status, and device status. It includes methods for device configuration, power management, and displaying device details, along with a static count of created devices. The Main1 class demonstrates creating SmartDevice objects, modifying their configurations, and displaying their details and total count.

Uploaded by

f24610012
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

public class SmartDevice {

private String device_type;


private String device_name;
private String model_number;
private String ip_address;
private int battery_percentage;
private boolean wifi ;
private String device_status;
private static int device_count;

public SmartDevice() {
device_name="unknown";
device_type="undefined";
ip_address="Not assigned";
model_number="Not assigned";
battery_percentage=100;
wifi=false;
device_status="off";
device_count++;

public SmartDevice(String device_type, String device_name, String


model_number, String ip_address, int battery_percentage, boolean wifi,
String device_status) {
this.device_type = device_type;
this.device_name = device_name;
this.model_number = model_number;
this.ip_address = ip_address;
this.battery_percentage = battery_percentage;
[Link] = wifi;
this.device_status=device_status;
device_count++;
}

public String getDevice_type() {


return device_type;
}

public void setDevice_type(String device_type) {


this.device_type = device_type;
}

public String getDevice_name() {


return device_name;
}

public void setDevice_name(String device_name) {


this.device_name = device_name;
}

public String getModel_number() {


return model_number;
}
public void setModel_number(String model_number) {
this.model_number = model_number;
}

public String getIp_address() {


return ip_address;
}

public void setIp_address(String ip_address) {


this.ip_address = ip_address;
}

public int getBattery_percentage() {


return battery_percentage;
}

public void setBattery_percentage(int battery_percentage) {


this.battery_percentage = battery_percentage;
}

public boolean isWifi() {


return wifi;
}

public void setWifi(boolean wifi) {


[Link] = wifi;
}
public static int getDevice_count() {
return device_count;
}

public static void setDevice_count(int device_count) {


SmartDevice.device_count = device_count;
}

public String isDevice_status() {


return device_status;
}

public void setDevice_status(String device_status) {


this.device_status = device_status;
}

public void turn_on(){


[Link](device_name+" is Turn on");
}
public void turn_off(){
[Link](device_name+" is Turn off");
}
public void device_detail(){
[Link]("Name : "+device_name);
[Link]("Type : "+device_type);
[Link]("Model : "+model_number);
[Link]("Status : "+device_status);
[Link]("IP Address : "+ip_address);
[Link]("Battery : "+battery_percentage);
[Link]("Wifi Status : "+wifi);
}

public void ConfigureDevice(){


[Link]("The Device is setup with default settings");
}
public void ConfigureDevice(String device_status){
this.device_status=device_status;
}
public void ConfigureDevice(String device_status, boolean wifi){
[Link]=wifi;
this.device_status=device_status;
}
public void ConfigureDevice(String device_status, boolean wifi, String
device_type){
this.device_status=device_status;
[Link]=wifi;
this.device_type=device_type;
}
public void ConfigureDevice(String device_status, boolean wifi, String
device_type, int battery_percentage){
this.device_status=device_status;
[Link]=wifi;
this.device_type=device_type;
this.battery_percentage=battery_percentage;
}
}

class Main1 {
public static void main(String[] args) {
// Creating SmartDevice objects with different configurations
SmartDevice laptop = new SmartDevice("Laptop", "Dell XPS",
"XPS15", "[Link]", 90, true, "on");
SmartDevice tablet = new SmartDevice("Tablet", "iPad Air",
"iPad2023", "[Link]", 75, true, "off");

// Displaying details of the devices


[Link]("\nLaptop Details:");
laptop.device_detail();

[Link]("\nTablet Details:");
tablet.device_detail();

// Testing power operations


[Link]("\nTesting Power Functions:");
tablet.turn_on();
laptop.turn_off();
// Modifying device configurations
[Link]("\nUpdating Device Configurations:");
[Link]("on", true, "Gaming Laptop", 85);
[Link]("off", false);

// Displaying updated details


[Link]("\nUpdated Laptop Details:");
laptop.device_detail();

[Link]("\nUpdated Tablet Details:");


tablet.device_detail();

// Displaying total device count


[Link]("\nTotal Devices Created: " +
SmartDevice.getDevice_count());
}
}

You might also like