The requirements for computer design are as follows: properties: Brand, color, cpu model, memory capacity, hard disk size, price, and working status; Method: Enable, disable, and sleep; create a computer object, call the open or close method,

Source: Internet
Author: User

The requirements for computer design are as follows: properties: Brand, color, cpu model, memory capacity, hard disk size, price, and working status; Method: Enable, disable, and sleep; create a computer object, call the open or close method,

The Code is as follows:

1 // Author: realjanushu 2 // Date: 17/9/28 3/* function: 4 design computer requirements: 5 6 attributes: Brand, color, cpu model, memory capacity, hard Disk size, price, working status; 7 8 Methods: open, close, sleep; 9 10 create a computer object, method 11 */12 public class ComputerDemo {13 public static void main (String [] args) {14 Computer c1 = new Computer (); 15 c1.open (); 16 c1.sleep (); 17} 18} 19 class Computer {20 String brand; // brand 21 String color; // color 22 String model; // model 23 int memory; // memory 24 int hardDiskStorage; // hard disk storage 25 String status; // working status 26 Computer () {}// display declaration default constructor 27 // initialization variable 28 public Computer (String brand, String color, String model, 29 int memory, int hardDiskStorage, String status) {30 // distinguish between member attributes and parameter 31 this. brand = brand; 32 this. color = color; 33 this. model = model; 34 this. memory = memory; 35 this. hardDiskStorage = hardDiskStorage; 36 this. status = status; 37} 38 // print out 39 public void open () {40 System. out. println ("turn on the computer"); 41} 42 public void shutdown () {43 System. out. println ("disabled"); 44} 45 public void sleep () {46 System. out. println ("Sleep"); 47} 48}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.