Posts

Java Program that Purchases a Computer from Datacenter in London and Install Ubuntu using Linode API

Image
Amazon AWS, Digital Ocean and Linode are well known cloud platform, infrastructure and other services providers. Below I explain how we can write a Java program that buys a computer from Linode London Datacenter, install Ubuntu OS and put it ON. Definitely, you can choose your datacenter of choice among following: Dallas, Fremont, Tokyo, London, Singapore, Frankfurt. I have selected London. Linode provide RESTful services to create and manage different resources e.g. linux box aka Linode, node balancers, setting DNS, IPs, Backup, Storage and scalling system resources. Below program use Linode RESTful API via official wrapper Java API. Lets move step by step: First of all, you must create an account at Linode.com. Login into your account, go to My Profile > API Keys and click on Create New API key. Note it down, we need it to make API calls. Download the Linode official Java API from  https://github.com/synapticloop/linode-api and add the linode-api.jar and runtime dependencie...

Assignment 4 - Point of Sale system

Develop a limited version of Point of Sale system. You have seen it already, its what a salesman use at medical or deparmentsal stores to make invoices. Making complete system is difficult at this level and need more time than we are left with. So build only following functionalities: (I recommend to save all data in MySQL database, DB lecture links already shared at FB Group, you can also use binay files, if you feel not comfortable with using MySQL after watching video lectures). Customers CRUD (Create, Retrieve, Update, Delete) and List functionality using Java GUI. Customer table and class shall have: id, name, email, gender, active, city, cellNumber Create means (provide short key: Ctrl+N), provide a JFrame based form to add new customer.  List means, show all customers ID-Name in JList, so that user could select the customer to perfrom Update, Show/Retrieve or Delete operation.  Update means, user shall be able to update the customer record. He shall select the custome...

Task 11: Java GUI Basics

Task 11.1: Make a form that shall look like this: Name: _____________ (Text field) Email: _____________ Gender: o Male    o Female   (radio button) Subjects: o OOP  o DB  o Web  o Android  o Machine Learning   [Check boxes]                 [ Submit ]            (submit button) Make a class User with name, email, gender and subjects instance attributes of type String, String, Boolean, and ArrayList<String>. When user fill above form and press the submit button, make an object of User using the form data and save that object on file using Serialization. When user run the program again, if user has saved the user object earlier, load the form with user existing data (explore some functions of Swing components using API docs and Googling). ~~~~~~~~~~~~~~~ Task 12 would be Assignment 4 and would be little complex using Swing programming. So make sure you have done task 11.

Task 10b - Interfaces and Exception Handling in Java

Create a UserService Interface with following methods. void addUser(User user) void updateUser(User user) void deleteUser(int userID) User getUser(int userID) void unblockUser(int userID) void blockUser(int userID) ArrayList<User> getAllUsers() Define InMemoryUserService class that shall implement UserService contract or interface. Use ArrayList for storage, update and retrieve operations inside InMemoryUserService i.e. you shall define a static attribute ArrayList<User> users = new ArrayList<>(); The implemented methods shall change/read this list to perform the required operation.  Test all methods from UserTest class. Getting information from user input is encourged but optional.  Define at least id, name, and status instsance attributes in User class of type int, String and Boolean. How you check whether a user account is blocked? If status attribute is false, it means user account is blocked. True represent the account is active. Make ...

Task 9 - Polymorphism in Java

9.1:  Make Circle , Rectangle , Square and Triangle classes that extends Shape.  Shape has color attribute and an abstract double calcArea() method. Circle has radius attribute. Triangle has base and height. Rectangle has length and width.  Square have only one attribute i.e. size (to represent width and height both, as both are same in case of square). In ShapeTest class's main method, ask the user how many shapes he want to create. Then, ask the type of each shape, then get the required data to instantiate that shape object. Keep putting each shape in ArrayList of type Shape . e.g. How many shapes you want to create: 4 Choose 1st Shape type: Press 1, to create Circle Press 2, to create Rectangle Press 3 to create Triangle Press 4 to create Square >1 Enter the radius of circle: > 5 .... .... Then outside the loop, display following information: Sum of area of each shape type  Total shapes of each shape type Total cost to paint each shape type  Cost t...

Task 8 - OOP Assignment 2 - Inheritance + Arrays

Image
Create a class Game with start, stop, restart methods. Define two protected attributes to store player 1 and player 2 names. Methods shall overridden by subclasses of Game class. Subclass shall decide what shall be written in the body of these methods depending on the particular game logic. Create a class TicTacToe, a subclass of Game, that will enable you to write a program to play Tic-Tac-Toe. The class contains a private 3-by-3 two-dimensional array. Use an enum type to represent the value in each cell of the array. The enum’s constants should be named X, O and EMPTY (for a position that does not contain an X or an O). The constructor should initialize the board elements to EMPTY. Allow two human players. Wherever the first player moves, place an X in the specified square, and place an O wherever the second player moves. You can get coordinates from each user to place X or 0. Each move must be to an empty square. If user a position that is already occupi...

Task 7 - Inheritance in Java

Last Updated on Nov. 26, 2020 Program 7.1  (With reference to Employee inheritance hierarchy, given in Chapter 9 of our reference book) You studied an inheritance hierarchy in which the class BasePlusCommissionEmployee inherited from class CommissionEmployee. However, not all types of employees are CommissionEmployees. In this exercise, you shall create a more general Employee superclass that factors out the attributes and behaviors in class CommissionEmployee that are common to all Employees. The common attributes and behaviors for all Employees are firstName, lastName, CNIC, getFirstName, getLastName, getCNIC and a portion of method toString. Create a new superclass Employee that contains these instance variables and methods and a constructor. Next, rewrite the class CommissionEmployee from Section 9.4.5 as a subclass of Employee. Class CommissionEmployee should contain only the instance variables and methods that are not declared in its parent type. Class CommissionEmployee’s co...