Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Digital assignment-1

Raghvendra singh sisodia


19bce1381
class Human{

String name;

String food= "pizza";

Human(){

this.name = "NULL"; //this

Human(String name){ //overloading

this.name = name;

//Overridden method

public void eat()

System.out.println("Human is eating");

class Boy extends Human{

String name;

Boy(){

this.name = "NULL"; //this

Boy(String name){ //overloading

this.name = name;

//Overriding method

public void eat(){


if(this.name=="NULL"){

System.out.println("Boy is eating");

else{

System.out.println(this.name+" is eating "+ super.food);

abstract class Girl extends Boy{

public void eat()

System.out.println("She is eating");

class Woman extends Girl{

interface HM{

public void run();

class Man implements HM{

public void run(){

System.out.println("running");

class Main{

public static void main(String args[]) {


Human h_obj = new Human();

Human h_obj_1 = new Human("Pandey");

Boy b_obj = new Boy();

Boy b_obj_1 = new Boy("Pandey");

Woman w_obj = new Woman();

Man m_obj = new Man();

h_obj.eat();

h_obj_1.eat();

//This will call the child class version of eat()

b_obj.eat();

b_obj_1.eat();

w_obj.eat();

m_obj.run();

}
JAVA PROGRAMING
DA-3

Raghvendra
singh sisodia
19BCE1381
1. Write a Java program in designing a colourful and informative user interface
for the current existing pandemic COVID-19 scenario exist in India.

CODE:

package
com.example;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class CoronavirusDashboardApplicationTests {

@Test
void contextLoads() {
}

package
com.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;

@SpringBootApplication
@EnableFeignClients
public class CoronavirusDashboardApplication {

public static void main(String[] args) {


SpringApplication.run(CoronavirusDashboardApplication.class,
args);
}

package
com.example;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
@FeignClient(name = "corona-ip", url = "https://corona-api.com/")
public interface CoronavirusService {

@RequestMapping(value = "/timeline")
Timeline timeline();
}

package
com.example;

import com.vaadin.flow.component.charts.Chart;
import com.vaadin.flow.component.charts.model.*;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;

import java.time.LocalDate;
import java.time.ZoneOffset;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class DashboardChart extends VerticalLayout {

public DashboardChart(List<Datum> data, ChartType type, String title,


Function<Datum, Number> getConfirmed, Function<Datum,
Number> getDeaths, Function<Datum, Number> getRecovered) {
Chart chart = new Chart(type);
Configuration configuration = chart.getConfiguration();
configuration.setTitle(title);
configuration.getTooltip().setEnabled(true);
configuration.getxAxis().setType(AxisType.DATETIME);
configuration.addSeries(getDataSeries(data.stream(),
getConfirmed, "Confirmed"));
configuration.addSeries(getDataSeries(data.stream(), getDeaths,
"Deaths"));
configuration.addSeries(getDataSeries(data.stream(),getRecovered, "Recovered"));

add(chart);
}

private DataSeries getDataSeries(Stream<Datum> data, Function<Datum,Number> function,


String name) {
DataSeries dataSeries = new DataSeries(data
.map(d -> new DataSeriesItem(

LocalDate.parse(d.getDate()).atStartOfDay().toInstant(ZoneOffset.UTC),
function.apply(d)
))
.collect(Collectors.toList()));
dataSeries.setName(name);

return dataSeries;
}

package
com.example;

import com.vaadin.flow.component.Text;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;

public class DashboardNumber extends VerticalLayout {

public DashboardNumber(String description, Number number) {


Div descriptionDiv = new Div(new Text(description));
descriptionDiv.getStyle().set("font-size", "small");

Div numberDiv = new Div(new Text("" + number));


numberDiv.getStyle().set("font-size", "xx-large");
numberDiv.getStyle().set("font-weight", "bold");
numberDiv.getStyle().set("margin-top", "0");

add(descriptionDiv, numberDiv);
}

package
com.example;

import com.vaadin.flow.component.board.Board;
import com.vaadin.flow.component.charts.model.ChartType;
import com.vaadin.flow.component.html.H1;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.server.PWA;

import java.util.List;

@Route("")
@PWA(name = "Coronavirus Dashboard", shortName = "Coronavirus",
description = "A Coronavirus dashboard app")
public class DashboardView extends VerticalLayout {

public DashboardView(CoronavirusService service) {


List<Datum> data = service.timeline().getData();
Datum latest = data.get(0);

Board board = new Board();


board.addRow(
new DashboardNumber("Confirmed", latest.getConfirmed()),
new DashboardNumber("Deaths", latest.getDeaths()),
new DashboardNumber("Recovered", latest.getRecovered())

);
board.addRow(
new DashboardChart(data, ChartType.SPLINE, "Cumulative",
Datum::getConfirmed, Datum::getDeaths,
Datum::getRecovered),
new DashboardChart(data.subList(0, 7), ChartType.COLUMN,
"Daily",
Datum::getNewConfirmed, Datum::getNewDeaths,
Datum::getNewRecovered)
);

add(
new H1("Coronavirus dashboard"),
board
);
}

}
Coronavirus dashboard

2792782 195468 772535

Cumul ative
Daily

You might also like