×
Samples Blogs Make Payment About Us Reviews 4.9/5 Order Now

Create a Program to Implement Classes in Java Assignment Solution

June 15, 2024
Chloe Wong
Chloe Wong
🇨🇦 Canada
Java
Chloe Wong, holding a master's in computer science from the University of British Columbia, has successfully completed over 900 Java assignments. Her proficiency includes array initialization, searching techniques, and exception management. Chloe's meticulous approach and dedication to delivering well-structured solutions make her a trusted expert for students aiming to excel in their programming coursework.
Key Topics
  • Instructions
    • Objective
  • Requirements and Specifications
Tip of the day
Focus on understanding TensorFlow's computational graph and its eager execution mode. Use pre-built functions like tf.data for efficient data pipelines.
News
The latest version of Google's machine learning library, offering improved performance, streamlined APIs, and expanded support for reinforcement learning, making it a powerful tool for AI development.

Instructions

Objective

Write a java homework to implement classes.

Requirements and Specifications

CMIS Homework Week 6

Design and implement your own simple class to represent any household item of your choice (toaster, fan, hair dryer, piano ...) Your class should have a constructor, one additional method and at least one member variable (e.g. boolean isOn to turn the item on or off). Be sure you demonstrate your class works properly by constructing an instance of it and calling your method.

Respond to other student postings by compiling, testing and enhancing their code submissions.

Source Code

/** * A laptop is a portable desktop computer. * * @filename Laptop.java * @date June 29, 2020 * @author Me */ public class Laptop { /** * Who made the laptop? E.g. Dell, HP, Samsung, Apple, etc. */ private String brand; /** * The model name given by the manufacturer e.g. Envy 13, Predator, XPS 15, * etc. */ private String model; /** * Windows, Linux, or Mac */ private String operatingSystem; /** * RAM Size in GB */ private int memorySize; /** * Disk size in GB */ private int storageSize; /** * Charge level from 0% to 100% */ private int chargeLevel; /** * Whether it is charging or not */ private boolean charging; /** * Whether it is on or not */ private boolean on; /** * Create a laptop. * * @param brand Who built the laptop * @param model Model name * @param operatingSystem OS name and version * @param memorySize RAM in GB * @param storageSize Storage amount in GB */ public Laptop(String brand, String model, String operatingSystem, int memorySize, int storageSize) { this.brand = brand; this.model = model; this.operatingSystem = operatingSystem; this.memorySize = memorySize; this.storageSize = storageSize; on = false; charging = false; chargeLevel = 100; } /** * Access to the brand property. * * @return Brand */ public String getBrand() { return brand; } /** * Initialize the brand property. * * @param brand Laptop manufacturer */ public void setBrand(String brand) { this.brand = brand; } /** * Access to the model property. * * @return Model */ public String getModel() { return model; } /** * Initialize the model property. * * @param model Model name */ public void setModel(String model) { his.model = model; } /** * Access to the operating system property. * * @return OS */ public String getOperatingSystem() { return operatingSystem; } /** * Initialize the Operating System property. * * @param operatingSystem OS */ public void setOperatingSystem(String operatingSystem) { this.operatingSystem = operatingSystem; } /** * Access to the memory size property. * * @return Memory Size */ public int getMemorySize() { return memorySize; } /** * Initialize the memory size. * * @param memorySize RAM */ public void setMemorySize(int memorySize) { this.memorySize = memorySize; } /** * Access to the storage size property. * * @return Storage size */ public int getStorageSize() { return storageSize; } /** * Initialize the storage size property. * * @param storageSize Drive space size */ public void setStorageSize(int storageSize) { this.storageSize = storageSize; } /** * Access to the charge level property. * * @return Charge level */ public int getChargeLevel() { return chargeLevel; } /** * Initialize the charge level. * * @param chargeLevel 0% to 100% */ public void setChargeLevel(int chargeLevel) { this.chargeLevel = chargeLevel; } /** * Check if it is charging. * * @return True if charging, otherwise false */ public boolean isCharging() { return charging; } /** * Initialize if charging or not. * * @param charging True if charging, otherwise false */ public void setCharging(boolean charging) { this.charging = charging; } /** * Check if turned on. * * @return True if on, otherwise false */ public boolean isOn() { return on; } /** * Initialize if on or not. * * @param on True if on, otherwise false */ public void setOn(boolean on) { this.on = on; } /** * Return a string representation. * * @return Details of laptop as string */ @Override public String toString() { String str = brand + " " + model + "\n"; str += operatingSystem + " OS\n"; str += memorySize + "GB RAM\n"; str += storageSize + "GB Device Storage\n"; str += chargeLevel + "% battery left\n"; if (on) { str += "is ON and "; } else { str += "is OFF and "; } if (charging) { str += "CHARGING"; } else { str += "NOT CHARGING"; } return str; } }

Similar Samples

Check Out Our Sample Solutions At Programming Homework Help, we provide detailed sample assignments to help you tackle your programming challenges. Each example is crafted by experts to enhance your understanding and improve your skills. Explore our samples and see how we can assist with your coding needs.